I’m really new at this mod_rewrite stuff and I’m trying to clean up the url from a new application.
I have 2 types of URL in the site. They are always one of the formats below:
http://www.site.com/dreams.php?page=view&p=23
http://www.site.com/dreams.php?page=view&p=20
http://www.site.com/dreams.php?page=contact
http://www.site.com/dreams.php?page=contests
Now in my main page (dreams.php) I always check to see if $page is set to display the content.
How do I client my url to have:
http://www.site.com/view/23
http://www.site.com/view/20
http://www.site.com/contact
http://www.site.com/contests
There is one exception to these pages which is when the user searches for content on the vendor page.
http://www.site.com/dreams.php?page=vendor_profile&pg=2&cat=&q=c&v_search=
I started playing with this but I’m getting some very strange results.
Options +FollowSymLinks
RewriteEngine on
RewriteRule /(.*)/(.*)/$ /dreams.php?page=$1&p=$2
Thanks a lot in advance.
The expression
.*is very broad and can consist of a forward slash as well, so to avoid unexpected situations, I would narrow it down, in your case:That would only rewrite:
Note that in your expression, you need to have at least 3 forward slashes to match.