I have a problem in rewriting my dynamic url pattern in localhost.
here is my url: http://localhost/realtor/?module=property&action=popular-residential-buy
and i want the url to be http://localhost/realtor/property/popular-residential-buy
I have done so far in my .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule type (.*)-(.*)$ /?module=$1&action=$2
but it’s not working.
Your existing regular expression gobbles up too much of your URL. You’ll end up with something other than what you want in $1 and $2 (probably
realtor/property/popular-residentialin $1, and justbuyin $2, due to the first .* greedily matching as much as it can before back tracking one character at a time to find a match).Based on the URL you provided, it looks like your regular expression should be something like
^realtor/([^/]*)/([^/]*)/?$. That will give you what you want in $1 and $2, and it should be a quicker regular expression AFAIK.Past that, make sure that you do have the RewriteEngine properly configured on your particular server.
LoadModule rewrite_module modules/mod_rewrite.so, and make sure it is uncommented.