php_guest Posted October 28, 2009 Share Posted October 28, 2009 Please could you help me how to write the rule to make 301 redirect from domainname.com/categoryname/example.php?page=4 to domainname.com/categoryname/4.html I tried RewriteRule ^domainname.com/(.[a-z]*)/example.php?page=(.[0-9]*)$ domainname.com/$1/$1.html [r=301,nc] but it is not working. thank you Quote Link to comment https://forums.phpfreaks.com/topic/179337-categoryexamplephppage2-to-category2html/ Share on other sites More sharing options...
cags Posted October 28, 2009 Share Posted October 28, 2009 It sounds like you have your theory back to front. I'd have thought you wanted to redirect domainname.com/categoryname/4.html to domainname.com/categoryname/example.php?page=4. The address you forward is the one typed into the address bar. Couple of things with your actually pattern. In the forwarded to address you are using $1 twice, which means the first pattern twice, wheras it seems more like you'd want pattern 1, then pattern 2. With regards to the actual patterns the fullstop means match any character, you then have 0 or more of a-z and 0-9 respectively. I think you can safely get rid of the fullstops. Quote Link to comment https://forums.phpfreaks.com/topic/179337-categoryexamplephppage2-to-category2html/#findComment-946298 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.