Msg#: 3168344 posted 7:41 am on Nov 26, 2006 (gmt 0)
I have some 301 redirect pages that instead of just redirecting, it gives me this message:
OK The document has moved here
Where the here is a hyperlink going to where the page supposed to go to.
It used to work on my server, but I just upgraded Apache, recompiled it with PHP5.
Here are some other details that may help...
301 redirects in my .htaccess file does not show this message. 301 redirects using PHP shows this. And I really want to use PHP in this case since the redirects are pulled from a database of old pages that no longer exist.
I am scanning my httpd.conf file looking for what I can change, but I can't seem to find anything yet.
Msg#: 3168344 posted 8:36 am on Nov 26, 2006 (gmt 0)
I found out this has nothing to do with Apache configurations. It is a PHP issue. Sorry for the wrong forum post. I didn't know this was a PHP problem and thought it was something I needed to configure in Apache.
But just to mention the solution to the problem:
<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.domain.com/path/file.html"); exit(); ?>
Of course the code above should come before everything else. And when I was using PHP4.3, it worked fine even if they were in some include() function. Now in PHP5, they need not only be the first thing in the file, but they cannot be in an include() function anymore if you want the forwarding to be automatic.
Note to Moderator: Sorry for the wrong forum post, could this be moved to the PHP forum?