Merging WordPress Multisite

When I first set up my personal website network, I got a bit carried away.  Once I had the first two sites in a multisite network, I started splitting out every category of my blog into its own site – each with its own domain.

At the peak, I had:

  • One site for my personal profile – linking to all the other sites
  • One site for a professional portfolio
  • One site for my business blog
  • One site for my Christianity blog
  • One site for my creative writing portfolio
  • One site for political discussions
  • One site for a personal journal

Then I read a great article by Ipstenu about why you shouldn’t use WordPress Multisite and decided I should rein things in a bit.  Categories of content should be categories instead of full sites.

This started a huge migration of content.  I set up a clean WordPress installation and started moving all of my posts, pages, categories, tags, etc from the schismed sites into the new one.  Everything was clean and ready to go … except for one thing. External links.

I’ve never understood why, but sometimes people actually like what I write.  They link to it.  People follow those links and comment.  So when http://mindsharestrategy.com/2011/how-to-publish-a-wordpress-plugin-subversion/ becomes http://eamann.com/tech/how-to-publish-a-wordpress-plugin-subversion/, what happens to my traffic?

Redirection

The first thing I did was install a plugin called Redirection on my new site.  I knew that my URL structure was going to be different before and after the merge, so I was able to set up redirects between the old structure and the new structure.

Using the URL structure above as an example, I mapped /2011/how-to-publish-a-wordpress-plugin-subversion/ to http://eamann.com/text/how-to-publish-a-wordpress-plugin-subversion/?ref=mindshare.

The query argument at the end does two things:

  1. It lets me track how many people are being directed to my site from old URLs
  2. It lets me display a message on my site explaining why the design and URL has changed if I want to

Server Configuration

Now that the redirects were in place, all I had to do was point the domains at the new location.

I use Nginx to power my WordPress sites, so pointing my Mindshare domain at my EAMann site was a matter of the domain as a [cci]server_name[/cci] in my configuration:


server {
listen 80;
server_name eamann.com mindsharestrategy.com;
root /home/s1/html/website;

# Rest of Nginx configuration below ...
}

Anyone trying to visit an old post or page from Mindshare Strategy is now redirected automatically to the same content on the new site.

Root Domains

Unfortunately, this failed to handle the root domain – all of my old domains stayed the same but presented content from the new site.  I could have mapped a redirect from / to http://eamann.com, but there’d be no way to see if the traffic was coming from Mindshare Strategy, Prose Painting, Grounded Christianity, or one of my other sites.

So instead of placing the domain directly in my main site’s configuration, I broke each domain into a separate server profile and used Nginx’ internal rewriting to redirect traffic:


server {
listen 80;
server_name mindsharestrategy.com;

location = / {
rewrite ^ http://eamann.com/category/biz/?ref=mindshare permanent;
}

location / {
rewrite ^ http://eamann.com$request_uri permanent;
}

This configuration still maps all post and page requests through WordPress so that the Redirection plugin can do its work.

It also forces a redirect of the root domain to a specific page I design – in the case of Mindshare Strategy, all visitors are mapped to the category archive for Business posts.