Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.