WordPress Multisite Migration Tipps

While transitioning from a normal WordPress single blog to WordPress Multisite, there were a few things to look out for. Nothing critical, but the solutions below might save you some time troubleshooting.

Multisite, the Idea

WordPress Multisite is just amazing if you run multiple blogs, or want to separate content better. Since 1996 I am running the site www.myrddin.de as personal website. In 2006 I switched to wordpress and have been writing about World of Warcraft. Slow updates and sparse new content of the Cataclysm Expansion made me want to cover other subjects, but at the same time I did not want to bring new topics to myrddin.de.

The solution to the issue is WordPress Multisite. This would allow to keep myrddin.de as it is and add new topics to subdomains. On top google classified my domain always as german domain, due to the top level domain.
It seems that MMO-Game.EU is a good domain for my purpose. I’d add subdomains for various games like Warcraft, Wildstar, Witcher or this TechTalk and have the excerpts of all posts show up on the Main page.

Which Next Steps?

This whole post is for the advanced user, going into detail would blow the dimension. If the tipps below will not work for you, they will at least help you to point you the right way. I’ll keep using mmo-game.eu and myrddin.de as examples (I find this always to adapt examples to my needs).

  1. create a brand new blog, www.mmo-game.eu
  2. convert it to a multisite
  3. add a new site as www.myrddin.de (site id = 6)
  4. import www.myrddin.de


So far so good … now make sure that your server is configured to serve both domains by adding this to your server configuration file.

ServerAlias *.mmo-game.eu *.myrddin.de

Also Plesk (my hosting application) needs to configured with myrddin.de as alias domain for mmo-game.eu (Subscriptions -> select Domain -> Website & Domains -> Show Advanced Operations -> Domain Aliases -> Add Domain Alias).

Now you need the WordPress MU Domain Mapping Plugin and add the Site-ID, Domain and check „as primary“ under Network Admin under Settings -> Domain.

Congratulations! Now your old blog is running under Multisite!

Themes Header and Background

Naturally I like to limit changes to themes as minimal as possible. It merely slows down the process of applying simple changes, especially when you’d need to do them over all networking sites or a series of themes. On mmo-game.eu I use only 2 themes, the blueish one here and the reddish one on the other sites.
Each site has his own background/header picture, even though the theme does not support it. This was accomplsihed by removing the background and header (the bold lines) below from the css and loading them via a cutoms css, per site.

Original style.css

padding: 0;
color: #FFFFFF;
background-color: #EFF2FA;
background-image: url('images/Bottom_texture.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: top center;
min-width: 1200px;
display: block;
left: 0;
margin-left: 6px;
position: absolute;
top: 8px;
width: 640px;
height: 64px;
background-image: url('images/header-object.png');

Then I created a folder „/custom/“ inside root directory and put the file 6.css inside it. 6 is the Site-ID of the myrddin.de blog.


background-image: url('/custom/bg-myrddin.jpg') ! important;
background-image: url('/custom/hd-myrddin.png') ! important;

As you can guess, the files bg-myrddin.jpg & hd-myrddin.png need to placed inside the /custom/ folder aswell.

Usually the stylesheet is called inside the header.php, we just add the new stylesheet next to the old one by inserting this line:

<link rel="stylesheet" href="<?php global $blog_id; bloginfo('url'); echo "/custom/" .$blog_id . ".css";?>" type="text/css" media="screen" />

Or if you want to have the custom folder inside your stylesheet folder

<link rel="stylesheet" href="<?php global $blog_id; bloginfo('template_url'); echo "/" .$blog_id . ".css";?>" type="text/css" media="screen" />

Mine looks like this:

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url') ?>" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php global $blog_id; bloginfo('url'); echo "/custom/" .$blog_id . ".css";?>" type="text/css" media="screen" />
<!--[if IE 6]><link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/style.ie6.css" type="text/css" media="screen" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/style.ie7.css" type="text/css" media="screen" /><![endif]-->

It may not be the most elegant solution, but it works for my purpose.

Sitewide Tags Pages

There is a must-have-plugin WordPress MU Sitewide Tags Pages. It will add the excerpts of all posts across the whole multisite to the main site and link them to the subsites, just like on www.mmo-game.eu now. It is such a powerful tool and so easy to use!

Broken Links

The transition to Multisite also means that the file structure is changing. Normal WordPress stores its files under /wp-content/uploads/ while Multisite uses /files/ This will cause many links to your log to end with a „404, file not found“ error. A simple rewrite rule in your apache configuration or .htaccess will fix this.

RewriteCond %{HTTP_HOST} myrddin.de
RewriteRule ^/wp-content/uploads/(.*)$ http://www.myrddin.de/files/$1 [R=301,L]

Both links, old and new lead to the same file.

Cleaning up Domains

Importing the blog to a subdomain, we did that as first step, linked all attachments to the subdomain instead of the proper domains. A file is linked as http://www.myrddin.de/custom/bg-myrddin.jpg instead of http://www.myrddin.de/custom/bg-myrddin.jpg.
Each site has a Site-ID and its tables are related to it. Myrddin.de has the Site-ID 6. Select the wordpress database in PhPMyAdmin and enter the SQL command below to replace all occurences from www.myrddin.de with www.myrddin.de.

update wp_mmo_game_eu_6_posts set post_content = replace(post_content, 'www.myrddin.de', 'www.myrddin.de')
update wp_mmo_game_eu_6_posts set guid = replace(guid, 'www.myrddin.de', 'www.myrddin.de')

Change Permalinks

While we are at it, it is probably a good time to change the permalink structure, too. I had been using the standard /YYYY/MM/DD/%postname% and thought it was the best time to change to /%postname%/ it may make wordpress sligthly slower, but the links look much cleaner.
Add the 2 lines below to the virtual host configuration file or .htaccess

RedirectMatch permanent /([0-9][0-9][0-9][0-9])/([0-9][0-9])/([0-9][0-9])/(.*)/ http://www.myrddin.de/$4/
RedirectMatch permanent /([0-9][0-9][0-9][0-9])/([0-9][0-9])/([0-9][0-9])/(.*) http://www.myrddin.de/$4/


To block comment spammers I am using a set of rewrite rules. One of them checks to see if an access to wp-comments-post.php comes from myrddin.de and blocks the request if it doesn’t. Since there are multiple domains in a multisite we need to check each domain (the subdomains are working fine).

# block comment spam by denying access to no-referrer requests
RewriteCond %{HTTP_HOST} myrddin.de
RewriteCond %{REQUEST_URI} .wp-comments-post.php*
RewriteCond %{HTTP_REFERER} !.*myrddin.de.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule ^(.*)$ https://www.xing.com/profile/Michael_Goeller/ [L]

Once for each domain while the last line sends these bots to my Xing Homepage, which has 54000 views already 😀

RewriteCond %{HTTP_HOST} mmo-game.eu
RewriteCond %{REQUEST_URI} .wp-comments-post.php*
RewriteCond %{HTTP_REFERER} !.*mmo-game.eu.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule ^(.*)$ https://www.xing.com/profile/Michael_Goeller/ [L]

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.