I am having some trouble rewriting and redirecting my URLs. This is what I am trying to do:
Currently I have this URL: domain.com/server.php?id=$1
I have that URL above which rewrites to: domain.com/details/$1
The problem I am having is when you go to: domain.com/server.php?id=$1
it doesn’t redirect to my SEO friendly URL.
Does anyone know why?
This is my current rewrite for the url:
RewriteRule ^details/(.*)/ server?id=$1 [L]
2
Answers
This is my what I found to work for me:
# external redirect from actual URL to pretty one RewriteCond %{THE_REQUEST} s/+server.php?id=([^s&]+) [NC] RewriteRule ^ details/%1? [R=301,L,NE]
# internal forward from pretty URL to actual one RewriteRule ^details/([^/.]+)/?$ server.php?id=$1 [L,QSA,NC]
Use this:
It will give you the URL:
domain.com/details/$1
. Just make sure you clear your cache before testing it.