How to move wordpress.com site to a sub domain hosted on IIS – Tips and tricks

I have recently moved my free wordpress.com blog (the one that you are reading) to my own domain.

If you read the contents on this site I hope you think I am reasonably technically savvy, but the feat of moving my site and redirecting the WordPress.com links was problematic and it took me a few days and many wrong turns to get it done.

I found that most instructions are based on apache/linux hosted solutions and I had issues using my IIS/Windows based host. My windows based host uses Plesk 10 (@ the time of writing).

Before you even begin to touch a computer there are a few things you have to think of first!

1. Root site or sub-domain?

Is this the only thing that you will have on your domain or are you going to have something else hosted on http://www.yourdomain.com? You need to answer this now as when you go to buy your domain mapping from wordpress.com you can only map a whole domain. So you would be better off hosting it @ http://blog.yourdomain.com, leaving the www for other things.

I started by creating my wordpress site with a click once install under a sub-directory in my httpdocs folder (main root web folder on my host), so I had my wordpress site setup @ http://www.homedev.com.au/ntsblog but as you can’t register a sub directory I had to start again.

So in my case I went and created a new sub-domain, https://ntsblog.homedev.com.au, and now I could register the sub-domain with my wordpress.com site.

2. Permalinks!!!!

Before you go any further you need to consider permalinks.

The issue

WordPress.com by default uses links that are styled as “Pretty Links” and default to a format of /%year%/%monthnum%/%day%/%postname%/” which means a posts will appear as http://blog.yourdomain.com/2011/11/31/post_title

The problem is that with version 3.2.1 of wordpress on a Windows host the “Pretty Link” is not supported by default and most “Permalinks” contain “index.php” in the path. see image..

Why is this a problem? Consider the link to your wordpress.com article that gets returned in a google search. When you try and do the domain mapping from wordpress.com to your domain, google will pass through a URL that your hosted wordpress site cannot handle.

This article discusses the various ways of mapping pretty links, and the section you are taken to is specifically for IIS/Windows systems.

http://codex.wordpress.org/Using_Permalinks#Permalinks_without_mod_rewrite

My hosting provider already had a copy of Microsoft “URL Rewrite Module”, so I created a web.config file as per the suggestion in this article and applied it to my site but it would not work.

Assume the URL was
https://ntsblog.homedev.com.au/2011/11/09/how-to-move-wordpress-com-site/

The URL re-writer would try to go to:

https://ntsblog.homedev.com.au/2011/11/09/how-to-move-wordpress-com-site/index.php/2011/11/09/how-to-move-wordpress-com-site/

In the end I did a little bit of tweaking and came up with the following solution…

web.config

Put this is the root directory of your wordpress site.
[xml]
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="redirect.php?path={R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
[/xml]

If you look at the “Action Type” link this is re-writing the url to go to a page called “redirect.php” passing in a parameter of the relative path. So we now need to create the “redirect.php” page.

redirect.php

Again, create this file in the root of you wordpress site.
[php]
<?php

$relative_url = $_GET[‘path’];
$new_relative_url = ‘index.php/’. $relative_url;
$hostname = $_SERVER[‘SERVER_NAME’];
$new_url = ‘http://’ . $hostname . ‘/’ . $new_relative_url;

header("Location: " . $new_url)

?>
[/php]
So what is this doing?
The URL re-writer matches the invalid URL and re-writes the url to “redirect.php”. This page then takes in the parameter, and rebuilds the full url to the site based upon inserting “index.php” in the chain. This works and also the “referrer” and “search engine” stats are not affected by the extra redirect.

To test this take an existing post on your new site, remove the index.php and paste that into a new browser window. The site should redirect to the index.php version. This means any link to your wordpress.com site will redirect to your new domain and be successfully passed along to the index.php page.

The only problem with this is that I don’t see how you could reverse the process and return to your wordpress.com site. The new articles will be found with index.php and if you try to go back to worpress.com as the primary domain the links with index.php will all break. Solution don’t go back. I will follow this up with wordpress and see if I can find a better solution.

Buy a domain from wordpress.com

Before you buy a domain read these wordpress articles about mapping domains or mapping sub-domains

Now seeing as I had created a sub-domain I went down the route of creating a CNAME entry. In plesk this means going to your DNSSettings and adding in a new CNAME. But being new to plesk I did not notice that when you make a DNS setting the settings shows with a warning like this
and right up on the top of the page you need to confirm the change by clicking Update.

So failing to notice that I handn’t saved the CNAME entry I gave up in frustration. So even though it told me not to I bought a domain and followed the full domain mapping instructions and it worked.

The instructions are fully mapped out in the mapping domains article but here are some extra tips.

  1. Go to your domain name provider site and find your name server settings, copy and paste them into a .txt document so you don’t forget them.
  2. With my name server provider, my names servers had a “Registrar Lock” on them. To update the ns1.wordpress.com, ns2.wordpress.com, ns3.wordpress.com, I had to
    1. Un-tick the checkbox and click save to clear the registrar lock.
    2. add the wordpress name servers and click save.
  3. now go to your wordress.com site and go to Store –> Domains.
  4. enter your domain, blog.yourdomain.com and click Add, follow the process to purchase the domain mapping
  5. Once registered, select your domain as the “Primary Domain” and click “Update Primary domain”
  6. Return to your name server and enter in the previous name server settings that you backed up to the text file.
  7. Re-enable the “Registrar Lock” if you have one.

Your wordpress site should now all be working.

What Plugins?

Now you’ve been using wordpress.com for a while and you probably have it configured how you like it, so how do you make your new site just like wordpress.com.
Most of the plugins on wordpress.com are special to wordpress.com, so I found it difficult to find and install the plugins to get the functionality I am used to.
So here is a mapping between functionality and the plugin you can freely download and install:

# wordpress.com Plugin Equivalent
1. Site Statistics Jetpack
2. Importer WordPress Imported
3. Ratings GD Star Rating

Other plugins I have found of interest;

  • Easy AdSense Lite
  • Google Analytics for WordPress
  • Preserve Code Formatting – keeps spaces and formatting when posting code snippets into your post.

Thats it for now.

Cheers
John

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.