Jump to content

Redirecting a page with variables


Masca

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]

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.