I am trying to write SEO friendly clean URLs, using Apache Mod-Rewrite.
My existing URLs look like this:
index.php?p=my-page
index.php?p=my-page&id=3
index.php?p=my-page&cat=5
index.php?p=my-page&month=201606
I have tried it and this is my code sofar in .htaccess:
RewriteRule ^([\w-]+)/?$ index.php?p=$1 [L,QSA,NC]
RewriteRule ^([\w-]+)/([0-9]+)/?$ index.php?p=$1&id=$2 [L,QSA,NC]
RewriteRule ^([\w-]+)/([0-9]+)/?$ index.php?p=$1&cat=$3 [L,QSA,NC]
RewriteRule ^([\w-]+)/([0-9]+)/?$ index.php?p=$1&mth=$4 [L,QSA,NC]
But, My problem is, when it change 2nd variable name in query string, its always identifying as id
not cat
or mnt
.
Can anybody tell me how fix this issue?
Thank you.