Redirect Old WordPress URLs to New When Moving or Rebuilding a Website

I’ve just moved my self hosted WordPress blog which was also my main business site with some static pages, to a WordPress hosted blog and replaced the self-hosted one with a static, hand made PHP/HTML website, with all new urls!

It’s proven to be a bit of a bigger job than I expected to redirect old urls that people and google might have indexed in such a way that any SEO merit I’ve gained over the years would not be lost.

Here’s what I done following some research online and while it’s not perfect and some urls are going to slip through the net or at least make people work harder to try find, I’m pretty happy with the outcome:

Step 1 – Transfer the content:

Transferring the content was easy enough. I simply done an export from my self-hosted WordPress admin and re-imported on WordPress.com. It usually works fine but some images might get lost. This will bring in Posts, Pages, Images, Categories, Tags, Comments…pretty much everything you need.

Step 2 – Replace old content:

I deleted all self-hosted WordPress files then built a new static site to replace the self-hosted WordPress site. The only thing to note here is that you should try match new url’s to old ones if possible, at least for the static pages that might have been on the old WordPress site. This will most likely involve using some code to create “pretty urls” though. More of that later.

Step 3 – Identify URLs to be redirected:

This is the hard bit! For me, all static page urls on my old site had to be redirected to the new url. I had to setup manual redirects for this even though the only difference in url might have been the addition of a .php or .html extension at the end. That was the easy bit but what about categories and single blog posts that might have been indexed quite well in google? My category list was fairly static so I could manually redirect each one similar to pages but unfortunately my permalink structure for single blog posts was a bit weird, ie – each url had a random number followed by the post title. If I’d have included the word “blog” in the url it might have made things easier!I basically had a good look through my post history on the new blog and identified the “most important” blog posts, ie – ones with affiliate links of just the most popular ones and even googled to see which posts came up highest. I also looked at my Google Analytics account to see which were the top bog posts viewed. Once I had a list of posts I was able to add redirect code for each post. See below:

Step 4 – Add the Redirect Code:

I added all my redirect codes to a .htaccess file in my website root. Here’s an extract below that should show and explain each redirect type:


Options +FollowSymLinks
RewriteEngine On
RewriteBase /

#Redirect Old WordPress Pages
Redirect 301 /web-design/ /web-design.php

#Redirect Old WordPress Categories
Redirect 301 /category/wordpress-tips/ https://reverbstudios.wordpress.com/category/wordpress-tips/

#Redirect Old WordPress Posts
Redirect 301 /67/web-design-leitrim/ https://reverbstudios.wordpress.com/2008/03/27/web-design-leitrim/

Step 5 – All Other URLs:

For anything else that might be in google but you haven’t redirected, it will end up on a 404 – not found page on your site/server. To get around this I simply created a new error 404 page with the same design as the rest of the new static site and put a line in the .htaccess file to redirect all missing pages or posts to that. Here’s the line:

ErrorDocument 404 https://www.reverbstudios.ie/404.php

Step 6 – Submit New Sitemaps:

Finally, I went into my various webmaster tools sites, ie – Google, Bing, Yahoo etc.. and deleted the old sitemap and added another new one.

As I said, this seems to work quite well for me but might not be an exhaustive list of things to do so please feel free to add anything I might have left out in the comments below.

Leon