Hosting multiple domains on WordPress MU

Recently I have been doing a lot of work with WPMU (WordPress MU) the version of WordPress which allows you to have multiple blogs all run on the same application, rather than installing multiple instances of WordPress.

WPMU is normally used for sites which want to allow people to register to set up their own blogs, and it is actually the application which powers WordPress.com which hosts millions of blogs, as well as being used for sites like Harvard’s law school blogs, Le Monde, and others in this WPMU showcase.

However WPMU can also be used to power multiple different websites on different domains. There are a couple of plugins which will allow you to “map” domains to different “blogs”. Here is how this works. Basically you install WPMU on any domain, where you want to host the WPMU application, for example lets say you install it on http://yoursite.com.

Now lets say you have 5 different websites each with their own domain. What you can do is create 5 separate blogs on http://yoursite.com, for example blog1.yoursite.com, blog2.yoursite.com, blog3.yoursite.com, blog4.yoursite.com and blog5.yoursite.com and then “map” each of your domains to one of these blogs.

So you might be asking yourself now what is the advantage of this setup is over just installing standard WordPress on each domain. The main advantage is that you don’t have to manage 5 separate WordPress installations, you just do the updates on one. As for plugins there are a large number of plugins created for WPMU, including the All-in-one SEO plugin – which you only need to maintain in one place – the mu-plugins folder, but you also have the flexibility for each site to have its own plugins. This saves time for 5 sites, so imagine the time it would save if you had 20 or 100 sites all running on WordPress.

Traditionally WordPress is a blogging platform however because it is so flexible, open source, and has so many different plugins, more and more people are using WordPress as a fully operating content management system (CMS) for normal websites. With a few simple changes in the templates you can basically have your site taking on nearly any design you want. This site for example is powered by WordPress.

How To Map Your Domains in WPMU

In fact if you have a blog on WordPress.com you have the paid option to map your own domain to your blog so people will see www.yourdomain.com instead of someblog.wordpress.com.

On WPMU there are a couple of good plugins you can use to “map” your domains.

1. The Domain Mapping Plugin from WPMUdev.org. This is available for premium subscribers. It is based on Donncha’s domain mapping plugin (see below).

2. The original Doncha’s domain mapping plugin. (Donncha is the guy who developed WPMU initially and does work on WordPress.com).

3. Multi-site manager plugin which you can use if you want to be able to have multipe domains running on WPMU, but each domain with multipe sub-domains or sub-folders.

Because WPMU was designed primarily for a single domain so that people can register their own blogs like, http://someblog.wordpress.com, the default installation advises you to select the shortest version of your domain name, i.e. yourdomain.com rather than www.yourdomain.com. This means when someone signs up for a blog on your site their blog will have a url like http://someblog.yoursite.com rather than http://someblog.www.yoursite.com.

Adding the www Prefix to the Domain Mapping Plugin

The problem with the domain mapping plugin is that when you try to map your multiple domains to your blogs, you end up with the non-www domains. This may not be a problem especially if you have a new site, but if you want to maintain the www. version of your domain (i.e. http://www.yourdomain.com instead of just http://yourdomain.com) then you need to make a few minor adjustments to the plugin.

How I got this to work was change the code which strips out the “www” frome the domains in the domain-mapping.php file (from the WPMUdev.org domain mapping plugin).

This allowed me to set up multiple sites working on WPMU all with the www. prefix and this worked for my setup, and I have not come across any side-effects yet, so make sure you test it fully with your set up if you make these changes.

Also note that if you update the plugin, you will overwrite your changes, so you will always manually make the same changes whenever there is a plugin update. Hopefully WPMUdev will allow for non-www or www in future if there is more demand for this feature. So here is the code….

Search for “www” in the file and replace…

$domain = $this->db->escape( preg_replace( "/^www\./", "", $_POST[ 'domain' ] ) );

…with…

$domain = $_POST[ 'domain' ];

I changed this in every function in the domain-mapping.php file (3 more times) and the domain mapping worked to the www versions of the domains.

If you want to add to this discussion please leave your comments below.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • StumbleUpon

Add your comment

Labs


Copyright © 2010 SEO Blog | Site Theme From miloIIIIVII | Top ↑