How To Redirect Permanently with PHP


To do a permanent redirection using PHP, for whatever SEO needs you may have, the code is

//Standard 404.php file

//Looking for my tnmailserver?
if(strpos($_SERVER[“REQUEST_URI”], “/Projects/TNMailServer-Full.aspx”) !== FALSE)
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: /TNMailServer”);

The exit is importantly, especially if you still have other code below this snippet performing other checks, or showing the standard 404 page.

Leave a Reply

Your email address will not be published. Required fields are marked *