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 Link to comment https://forums.phpfreaks.com/topic/68336-php-5-301-redirects/ 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"; Link to comment https://forums.phpfreaks.com/topic/68336-php-5-301-redirects/#findComment-343601 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 Link to comment https://forums.phpfreaks.com/topic/68336-php-5-301-redirects/#findComment-343604 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? Link to comment https://forums.phpfreaks.com/topic/68336-php-5-301-redirects/#findComment-343606 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.