<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/");
exit();
?>
2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by dap62
0

That is one way to do it, and it does work. It does require that you have the redirection php file on the same path, and the same file name as the previous file. However, if the previous file had a file name extension other than a php file extension, it won't work (unless you use some additional tricks).

If you are using Apache for your HTTP server, there is an easier solution. You can put the following line in the .htaccess file in the website instead.

RedirectMatch permanent ^/path/old_filename.htm$ http://www.domainname.com/path/new_filename.htm

Where "/path/" would be the old directory path to the old file from html_public root, and "old_filename.htm" is the name of the old file that no longer exists on the web server. The new target file would be specified with ""http://www.domainname.com/path/new_filename.htm". Including the keyword "permanent" will cause a 301 status code to be returned with the redirection, as opposed to "temporary" which would return a 302 with indicates a temporary URL change.

Don

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.