Jump to content

PHP 5, 301 redirects


mrb1972

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.