Easy Wordpress .htaccess 301 Redirect

October 17, 2008 by Ms. Crafty · Blogging with Wordpress, Tutorial · 1 Comment 

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 redirects.

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.

Print

{ 1 comment… read it below or add one }

1 Jeff Walden December 27, 2009 at 7:14 pm

Um, you’re a genius! Thanks so much for this tip. Saved me from creating a LONG list.

Leave a Comment

CommentLuv Enabled