Easy Wordpress .htaccess 301 Redirect

October 17th, 2008 · No Comments · Blogging with Wordpress, Tutorial

Recently, I moved a Wordpress blog from one domain to another. Most of the time, I work with blogging platform transfers or possibly moving the domain from one host to another.

In this case, I needed to direct traffic arriving at any page on the old domain to the same page on the new domain. I knew that I wanted to do a 301 redirect, but I hadn’t anticipated how simple the whole thing would be. I had anticipated a long list of redirect.

But it turns out that if you migrate a Wordpress blog from one domain to another domain, then all you need to do is make a small change to your .htaccess file at the old domain.

If there isn’t anything about the “RewriteEngine” in the .htaccess file, then add the following:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Replace www.newdomain.com with whatever your new domain is. Use “www” or not as you see fit.

However it’s quite likely that in the section following:

# BEGIN WordPress

you’ll find the first two lines:

Options +FollowSymLinks
RewriteEngine on

Directly after those, before any other rewrite commands, place:

RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

again replacing www.newdomain.com with the blog’s new domain.

This works on Linux servers which have Apache Mod-Rewrite enabled. That sounds very technical, but it’s also what’s offered by a large number of hosting companies. If you don’t know whether or not you have that, give the redirect a shot. You can always contact your hosting company if it doesn’t work and ask for their suggestions.

It takes about 20 seconds to do. And this works whether or not you still have Wordpress installed on the old domain. I deleted the entire Wordpress installation and just left the redirect up. Every link goes through to the new site.

A 301 redirect isn’t as good as a direct link, but in terms of traffic and even SEO it’s a best choice. Gives you time to find out who’s linking to your old site and ask them to change while making people follow those old links to the right place anyway.

Related posts:

Tags: ····

| Print This Post Print This Post

0 responses so far ↓

  • Be the first to comment!

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>




Comment moderation has been enabled. While most comments make it through, some (especially from first-time commentators) are sent to me for moderation. I'll try to get to them as soon as possible, but it may take some time, depending on whether or not I'm online. If your comment hasn't posted in 24 hours and you remember, please drop me a line and I'll double check the spam filter. Thanks so much!