mrb1972 Posted September 7, 2007 Share Posted September 7, 2007 Hi, I wonder if anyone can point me in the right direction, I recently moved my site to a new server running php 5, which has caused a problem with 301 redirect. Instead of automatically redirecting like it use to i now get a message: "OK The document has moved here." here being the link to the new url.. this didnt happen on the old server it just redirected automatically, Im told its PHP5 thing!!, my site uses this function function redirectIfWrongURL($correcturl) { global $vchSiteUrl; /* does a 301 redirect to the correct URL if the actual URL is different */ $actualurl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; if (isset($_SERVER["HTTP_X_FORWARDED_HOST"])) { $actualurl ='http://'. $_SERVER["HTTP_X_FORWARDED_HOST"] . $_SERVER['REQUEST_URI']; } if ($correcturl != $actualurl) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $correcturl); echo '<br>This page has moved to <a href="' . $correcturl . '">' . $correcturl . '</a><br />Old URL: ' . $actualurl."<br />\n";; //print_r($_POST); exit(); } } Anyone have any idea? thanks Quote Link to comment Share on other sites More sharing options...
xyn Posted September 7, 2007 Share Posted September 7, 2007 try this? echo "<br>This page has moved to <a href=".$correcturl.">" . $correcturl . "</a><br />Old URL: " . $actualurl."<br />\n"; Quote Link to comment Share on other sites More sharing options...
mrb1972 Posted September 7, 2007 Author Share Posted September 7, 2007 I havent tried your suggestion yet, but i did get it working by changing header("HTTP/1.1 301 Moved Permanently"); to header('Status: 301 Moved Permanently'); I dont know if this is the correct fix, but it seems to work Quote Link to comment Share on other sites More sharing options...
xyn Posted September 7, 2007 Share Posted September 7, 2007 ohh sorry i mis-read it. erm are you using header() to redirect? Quote Link to comment 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.