Jump to content

category/example.php?page=2 to /category/2.html


php_guest

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.