Jump to content

Recommended Posts

Hi!  I have searched and searched, and I cannot find a solution to what I think should be a very simple redirect.  I need to permanently redirect:

 

www.domain.com/this_page.php?this=that

to:

www.domain.com/another_page.php?this=that

 

However, all my attempts result in a 404.  I feel so stupid :-(  Please help! TIA!

Link to comment
https://forums.phpfreaks.com/topic/198899-redirecting-a-page-with-variables/
Share on other sites

Anything after the question mark is considered to be the 'Query String' and this is ignored by RewriteRule. Does everything that references this_page.php want to go to another_page.php? If so then something like...

 

RewriteRule ^this_page\.php$ /another_page.php [R=301,QSA]

 

...otherwise if the redirect does only want to happen given certain values for the query string you will need to use a RewriteCond which can be done something like this...

 

RewriteCond %{QUERY_STRING} this=([0-9])
RewriteRule ^this_page\.php$ /another_page.php [R=301,QSA]

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.