How can I redirect somepage.php?location=125 to page.php? I tried the following, but it didn't work: Redirect 301 /somepage.php?location=125 http://www.domain.com/page.php Please help! Thanks.
Use mod rewrite as follows : RewriteEngine on RewriteRule ^somepage.php?location=(.*?) http://www.domain.com/page.php [L]
Hmm I tried that, but it says, "The requested URL /somepage.php was not found on this server." just like it was before. Any ideas?
i think the "?" in the RewriteRule creates an issue. Try This RewriteEngine on RewriteCond %{QUERY_STRING} location=(.*) RewriteRule ^(.*)somepage.php$ page.php?q=%1 [L]
Thanks, that seems to be working. However... I do have more than one location.. for example ( location=125 goes to page.php ) and location=126 would go to simple.php and so on. Can I replace (.*) with the number or would that not work? How would I do that correctly?
Yes, That would work, The final script would be like RewriteEngine on RewriteCond %{QUERY_STRING} location=125 RewriteRule ^(.*)somepage.php$ page1.php [L] RewriteCond %{QUERY_STRING} location=126 RewriteRule ^(.*)somepage.php$ page2.php [L]
Perfect, thanks. +rep added to all those who helped. Also, can you check this thread? -- http://forums.digitalpoint.com/showthread.php?t=1161300