Moving WordPress to a New URL and New Permalink Structure

When I decided to change the permalink structure and move my WordPress blog from to, I knew it was going to be a delicate process. I have over a thousand posts, more than three hundred of which have been indexed by Google. A huge portion of my traffic comes from Google, so my biggest concern was that the old URLs redirect to the new location.

Step 1: Disable plugins

It's a good idea to disable your plugins before making these changes. At the very least, if you have a caching plugin installed (such as WP Super Cache), delete the cache and then disable that plugin.

Step 2: Change the blog URL

First, I had to change the WordPress blog URL from to This is simply a matter of updating the "WordPress address" and "Blog address" options from within the WordPress Administration panel (Settings -> General).

Second, I wanted the final URL to be, instead of To do this, I first changed the "Blog address" to Now to get WordPress working on the web root (, I had to move /blog/index.php to the web root (/index.php) and then edit index.php and change this line,


to this,


Now, when index.php is loaded, it knows to look for all the WordPress files in /blog/ and since WordPress has been configured to use as the "Blog address", it will automatically handle everything else.

Step 3: Redirect old URLs to the new URL

The blog. sub-domain maps to a directory in the web root called /blog/. If someone visits a link to a page that includes the sub-domain, the web server needs to tell the browser the new location. To do this, I needed to recreate the /blog/ directory and add the following to an .htaccess file:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

Now, if someone tries to visit, the web server will do a 301 redirect to

What's a 301 redirect? Well, when you move a web page from one location to another, you can specify the type of redirection. A 301 redirect means the web page has been moved permanently. This is useful for keeping indexes updated. For example, if someone searches Google and finds an old link, Google will detect the 301 redirect and update its index with the new URL, thereby keeping your URL's page rank.

Step 4: Change Permalink structure

To change the permalink structure, I used the awesome Permalink Migration plugin by Dean Lee. With this plugin, I just specify the old permalink structure (in my case, this was /%year%/%monthnum%/%postname%/) and then change the permalink structure in WordPress (Settings -> Permalinks) to the new format (I'm using /%postname%/).

Now whenever someone visits a URL using the old permalink structure, Dean's plugin sends a 301 redirect to the new URL.


With the .htaccess rewrite rule and Dean's Permalink Migration plugin, we now have a double 301 redirect to make sure the old URLs redirect to the new ones:

  1. Someone searches Google and finds this link to my site:
  2. The .htaccess rule rewrites the URL and redirects:
  3. Dean's Permalink Migration plugin redirects to the new permalink structure:

Write a Comment


    • Hi Tom,

      Try changing this line:
      RewriteCond %{HTTP_HOST} ^$

      to this:
      RewriteCond %{HTTP_HOST} ^$

      Hope this helps!


  • Colleen Greene November 29, 2010
  • Site Update: A New Theme « Raam Dev November 29, 2010
  • Raam Dev November 29, 2010