Tag Archives: domain

WordPress: Switch to a New Domain by Setting a Permanent Redirect 301 via .htaccess CodeUnit 30 JUL 2012

Deciding that I really don’t have the desire nor free time to support multiple websites across multiple domains, I’ve started the process of copying all the content over from my unwanted WordPress sites to my primary WordPress site (at http://www.craiglotter.co.za) and then removing the unwanted installations. (Note: The WordPress Export/Import tools found under Tools work pretty damn well.)

However, because my unwanted sites still carry some decent link juice, SEO and SERP scores, I don’t necessarily want to lose all of that search engine goodness, and so set about setting up permanent redirection (301 HTML header) notices using the .htaccess file in the old accounts.

What this does is tell any search spider or browser where the content now sits, as well as the fact that it is a permanent redirect, meaning that hopefully the search engines update their indexes accordingly. Anyway, that’s the plan, but nevertheless, at least if you click in via an old link, you will still get transported to the desired content, albeit on a new domain! :)

To achieve this, first open your .htaccess file which you will find in the root of your WordPress installation directory. Note that this is a hidden file so you’ll need to edit it either via an FTP client or some other interface which allows you to list hidden files.

Once opened, be sure to remove all the WordPress rewrite rules which can be located between the “# BEGIN WordPress” and “# END WordPress” tags. Next, populate the .htaccess file with the following text at the top of the file:

<IfModule mod_rewrite.c>
# Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://www.craiglotter.co.za/$1 [R=301,L]

# BEGIN WordPress
# END WordPress

Save the file and then try to hit an old URL like “http://www.codeunit.co.za/2010/01/16/php-simple-try-catch-example/” and note your browser automatically heading off to “http://www.craiglotter.co.za/2010/01/16/php-simple-try-catch-example/”.


And the New Domain is Good to Go! Blogging 07 OCT 2009

Wow, that was pretty quick and painless. In case you’re wondering what I’m referring to, check the URL you suddenly find yourself at. Yup, finally went ahead and grabbed my vanity URL, meaning that now you’ll find all my goodness sitting at http://www.craiglotter.co.za.


Anyway, everything should be working pretty much as it used to, though you’ll notice a couple of slight branding differences slipping in here every now and then. Now just to get all of the blog.codeunit.co.za friendly URLs to redirect correctly as well…

internet browser