HI I got a blog that I am trying to rewrite search engine friendly urls. I have 3 different parameters for a script:
www.domain.com/index.php?p=1234
www.domain.com/index.php?m=1234
www.domain.com/index.php?cat=1234
I've written rules so it recognizes the url:
[domain.com...] to be served by [domain.com...]
Just trying to figure out how to flatten the files according to parameter variables using a condition.
i.e.
www.domain.com/index.php?p=1234 => www.domain.com/p/1234
www.domain.com/index.php?m=1234 => www.domain.com/m/1234
www.domain.com/index.php?cat=1234 => www.domain.com/cat/1234
Here's what I have so far in my .htaccess file:
Options +FollowSymLinks
RewriteEngine on
#case parameter 'p' post
RewriteCond %{QUERY_STRING} ^p=([0-9]+)
RewriteRule ^$ /p/%1/ [R]
#case parameter 'm' post
RewriteCond %{QUERY_STRING} ^m=([0-9]+)
RewriteRule ^$ /m/%1/ [R]
#case parameter 'cat' post
RewriteCond %{QUERY_STRING} ^cat=([0-9]+)
RewriteRule ^$ /cat/%1/ [R]
#rewrite the individual fake folders
RewriteRule ^m/([0-9]+) /index.php?m=$1 [L]
RewriteRule ^p/([0-9]+) /index.php?p=$1 [L]
RewriteRule ^cat/([0-9]+) /index.php?cat=$1 [L]
I have also tried the following:
Options +FollowSymLinks
RewriteEngine on
RewriteRule index/(.*)/(.*)/$ /index.php?$1=$2
But neither work for whatever reason.
Thanks!