I have a page details.php with URL domain.com/details.php?id=a&s=b I want it show domain.com/details/a/b.htm in address bar. I write this rule in .htaccess : <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine on RewriteRule ^details/([^/]+)/([^/]+).html /details.php?id=$1&s=$2 [NC] </IfModule> But it not works. I confused what's wrong with my rule ? Help me please
The following should work RewriteRule ^details/([^/]+)/([^/]+)\.html details.php?id=$1&s=$2 [NC] If not are you getting any error messages or anything?
I tried it on one of our servers here and it's working for me, the whole .htaccess I used is: RewriteEngine on RewriteRule ^details/([^/]+)/([^/]+)\.html details.php?id=$1&s=$2 [NC] Code (markup): Your host does support mod_rewite? One thing I just noticed is you have: I assume that's a typo and you meant: domain.com/details/a/b.html Code (markup): The rewrite rule above and your original both need .html if you want .htm the the following should do it: RewriteEngine on RewriteRule ^details/([^/]+)/([^/]+)\.htm details.php?id=$1&s=$2 [NC] Code (markup):
I asked about this to my host and they said that support mod-Rewrite and maybe my code is wrong. They told me to review my code again It's okay if URL will end .htm or .html. I just want to make the URL clean and SEO friendly But thanks for your help
I'm just wondering if I'm trying to fix the wrong thing. So if you manually enter details/a/b.html into your browser address bar does the correct page show? Then when you say your URLs like before do you mean that links on your site are still in the form domain.com/details.php?id=a&s=b they will be, you will have to modify the script and/or static links to be in the new format, rewrite only works on the incoming data not the forming of the URLs.