defeated Posted May 3, 2009 Share Posted May 3, 2009 I noticed that one of my pages is incorrectly indexed by google.... presumably I added a link badly somewhere. The problem page request mypage.php?page= As you can see there is no value for the page variable. It should read mypage.php?page=contact If I try to redirect like so... RewriteRule ^mypage.php?page= mypage.php?page=contact It ends up in a loop. That makes sense but I can't figure out how to do it. Any resident geniuses able to help me out here? Unfortunately the incorrect version is the one that google has indexed which has resulted in the page title showing up as the default " Uh oh, somethings wrong around here ". Shame because it's at number one in google for a specific search term. I have blocked in in my robots.txt and added it for removal but it would be nicer to have a redirect. Quote Link to comment https://forums.phpfreaks.com/topic/156656-redirecting-query-strings/ Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted May 4, 2009 Share Posted May 4, 2009 You can use php to redirect it if the page is invalid like this : $validpage = array('home', 'info', 'contact'); if (!(in_array($_GET['page'], $validpage))) { header("HTTP/1.0 301 Moved Permanently"); header('Location: http://www.example.com/'); die(); } Which is a good security pratice too preventing any bad input (like SQL Injection). Quote Link to comment https://forums.phpfreaks.com/topic/156656-redirecting-query-strings/#findComment-826216 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 I don't get how that RewriteRule would result in a loop. ??? Anyone care to explain? Quote Link to comment https://forums.phpfreaks.com/topic/156656-redirecting-query-strings/#findComment-830879 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.