How to redirect your website to a new domain name.
If you are moving your site from one domain name to another you are going to want to redirect traffic from one site to the other. One thing to keep in mind is that search engines won’t necessarily know about the new site right away and a proper 301 Redirect can help. Using the META refresh tag isn’t a good idea because you could get penalized in your search engine rankings.
Search engines don’t really like duplicate data, so if you use a META refresh tag instead of an actual 301 redirect, your search engine ranking could actually drop. This is because there is still content being displayed when using the META refresh method. The problem with the 301 redirect is that most people don’t know how to do this without modifying their web server settings. Most hosting companies don’t allow the settings you need to do a proper redirect either.
The good news is if you run PHP or any other scripting language on your site you can programmatically set the 301 Redirect. The following is the php code that will modify your headers for a proper 301 redirect. <?php header( “HTTP/1.1 301 Moved Permanently” ); ?> Below is a better code base to use if you use a template based php website such as wordpres, phpNuke or even Joomla.
<?php
$page = $_SERVER[‘REQUEST_URI’];
header(‘HTTP/1.1 301 Moved Permanently’);
header(‘Location: ‘ . $page);
die;
?>
This code will not only provide the correct 301 redirect header search engines are looking for, but it will also tell the search engines and browsers where the page has moved to. All web browsers will also forward the user automatically to the new location. Using this code will help you easily move your website from one domain name to another if using a PHP based site.
