Subscribe to RSS

Upgrading And Moving WordPress, 301 Redirects

I didn’t write a post about it but last Thursday I performed the long overdue upgrade from WordPress 2.0.4 to 2.1.3. I had tried to put it off for as long as possible for fear of plugin incompatibilities, but to my surprise only one plugin is not working after the upgrade.

The upgrade itself was pretty seamless. I downloaded the MySQL database containing all my posts as a backup, then copied over all the WordPress files to my desktop via FTP and I was ready to start. First, I deactivated all of my plugins. Second, I had to overwrite all of the files sans .htaccess, wp-config.php and the wp-content folder (where all the plugins and themes lie). Finally, I re-activated all of the plugins one-by-one to ensure that nothing would “break” the new install. The upgrade went off without a hitch for the most part, as I mentioned that only one plugin did not work after the upgrade — the “Top Commenters” plugin in the footer.

OK so now that I had the newest version of WordPress, it was time to tackle another issue that had been bothering me, the location of my blog on my server. Shortly after setting up this blog, I moved it from jonholato.com to jonholato.com/blog. At first I liked the idea of splitting up my site into sections and having my main domain home page as a portal. However, after other areas of the site failed to materialize and I realized that I spend most of my time working on the blog, I decided that I wanted it back in the root of the domain at jonholato.com. The new question that arose was, OK, now how do I move it?

I’m not going to document the step-by-step process of how to move your blog around your site, as there already exists plenty of documentation on that subject. I simply followed the Moving WordPress entry in the WordPress Codex, which gives a detailed instructional breakdown, and the whole process was very easy and straightforward. Rather, I want to focus on a different issue that some of you may also encounter when desiring to move your blog — maintaining search engine listings.

Naturally, when you move your blog around the links of your blog posts will get messed up. For example, my blog home page was jonholato.com/blog, and is now jonholato.com. Thus, if someone tried to access the old home page they would get a 404 Not Found error, which is not only bad for user experience, it’s also a no-no for search engine spiders. Sure, we could use custom error pages and catch all of the traffic trying to access the old links and get them back to the site again, but I wanted to go one step further. I have a number of posts which are well positioned in the search engines and drive a fair amount of traffic to me, so rather than drive these visitors to a custom error page, I wanted to drive them to the post they clicked on in the search engines, even if it was to the old link that is indexed. How would I do this, you ask? A little customization of the .htaccess file.

To better illustrate this scenario let’s look at an example. One particular post that I receive a fair amount of traffic on is my post about the closing of Roxy in New York City. I am fortunate enough to be on the first page of Google for a number of related keywords. So, here is my listing on the first page of Google for a search of: roxy nyc closing.

Roxy NYC Closing

The thing to notice with this picture is that the URL Google has indexed is the old one, as the entry is clearly found in the /blog sub-folder on the jonholato.com domain. So what we want to do is make sure that searchers who click this link are sent to the new location of the post, which is the same path as what Google is showing, minus the /blog folder. Otherwise, if we did nothing, anyone who clicked on this link would be sent to a 404 error page. In addition, however, we want to tell Google that the location of this post has changed, and to update it’s index with the new location. We can accomplish both of these tasks with a simple line of code:

301 redirect

What we’re looking at here is an exact copy of my .htaccess file. Lines 3-12 are a result of customizing my Permalinks in the admin panel. The focus here is line 1, which I added in to accomplish both the tasks we just discussed. Basically what line 1 says is to 301 redirect any requests made to jonholato.com/blog to jonholato.com. Thus, when someone types in “roxy nyc closing” into Google and clicks the old URL that is indexed, not only will they be sent to the correct and new URL, but it will also tell Google to update it’s index to the new URL. And the best part about it, that one line is applicable to any link on your site.

I hope this 301 redirect tip can help other bloggers out there. It truly makes it easy to ensure you don’t lose any quality traffic while helping search engines with their listings of your site. Please leave any questions you have below as I am happy to help when needed.

UPDATE: After posting this a few minutes ago I decided to run a “roxy nyc closing” search query on Google, and as a testament to the effectiveness of the 301 redirect discussed in this post, the Google index has already been updated to reflect the new blog structure:

Roxy NYC Closing Google Listings

Note, I implemented this 301 redirect Friday night, so in about 2 days it’s seeing the new URL. Pretty nifty! :)

5 Comments

  1. Posted May 14, 2007 at 12:38 pm | Permalink

    aww, my minion is all growns up.

  2. Posted May 14, 2007 at 2:06 pm | Permalink

    The question is, could the teacher have done this without the minion?

  3. Posted May 16, 2007 at 9:02 am | Permalink

    oh HELL no

  4. holderdebolder
    Posted May 16, 2007 at 10:04 am | Permalink

    wow, right when i needed it,

    did a google search and this page was already indexed ( may 16 )

    fast

    thanks for the info

  5. Posted May 16, 2007 at 3:48 pm | Permalink

    @ holderdebolder - glad this can be of help to you, clearly it works given the quickness with which it got indexed by Google :)

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*