Masca Posted April 18, 2010 Share Posted April 18, 2010 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 More sharing options...
Masca Posted April 18, 2010 Author Share Posted April 18, 2010 This is my current effort ('that' in my original post should always be 4 digits, e.g.: 1234): RewriteRule ^this_page.php\?this=([0-9]+)$ another_page.php?this=$1 [R=301,L] Where am I going wrong please!? Link to comment https://forums.phpfreaks.com/topic/198899-redirecting-a-page-with-variables/#findComment-1044053 Share on other sites More sharing options...
cags Posted April 18, 2010 Share Posted April 18, 2010 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] Link to comment https://forums.phpfreaks.com/topic/198899-redirecting-a-page-with-variables/#findComment-1044143 Share on other sites More sharing options...
Masca Posted April 18, 2010 Author Share Posted April 18, 2010 cags, thank you SO much! I can't tell you how long that's been causing me problems! It's now working perfectly. Thanks again! Link to comment https://forums.phpfreaks.com/topic/198899-redirecting-a-page-with-variables/#findComment-1044245 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.