After I thought of moving my domain to a new one and successfully moved my site to a new location, I always wondered what would happen to my search engine results. And so was the Permanent Redirect 301.
Permanent Redirects are one of the important concepts in site transfers, as well as in Search Engine Optimization. Basically if you have a house or an office and you wanted to move to a new location, you would not just leave your clients or visitors behind without knowing were your new location is.
With a WordPress system, I looked for ways to minimize usage of plugins and minimize code insertions and code modifications. For this to work, as much as possible, I tried to construct a code that is pretty simple and straightforward. Go to your Themes Editor, edit your header.php file, and copy the code below and paste at the very first line. So here goes:
$uri = $_SERVER['REQUEST_URI'];
wp_redirect(('http://newdomainname.com'.$uri),301);
What this code does is that, first, it gets the page or post permalink of the requested URL with the old domain name stripped off, concatenates it to your new domain name (‘http://newdomainname.com’), and leaves a 301 Redirect Code saying “Hey, this page is permanently moved to this new location.” No plugins needed, lesser code modifications, no .htaccess, Apache, or PHP configurations needed.
Just a few reminders if making use of this:
- This works for WordPress systems only. If you are using Joomla, Drupal or any other system, sorry but this can’t help you. :(
- Make sure your new WordPress blog has the same Permalink structure as your old one. I simply made this straightforward 301 Redirect of same URLs.
- Redirection code varies. 301 for Permanent Redirection, and 302 for Temparary Redirection, and it all depends on your needs.
There you have it. I hope this resource can quickly help you. Special thanks to all the sources and references out there. :D

Discussion
No comments yet.