Managing multiple domains in Wordpress MU

September 15th, 2009  |  Published in wordpress mu  |  1 Comment

update: 2009-09-30 Strike’d out steps that are not needed

These steps have been tested using Apache on a VPS using Parallels Plesk environment but they can be applied to any similar setup. For the purposes of this post lets say you have the following domains: rootdomain.com, otherdomain1.com & otherdomain2.com that you want to manage from one Wordpress MU setup.

Organise the domains

Create the following subdomains off rootdomain.com

sites.rootdomain.com , od1.sites.rootdomain.com & od2.sites.rootdomain.com

( note these are 3 seperate sub domain names and that od1/od2 are not subdomains of sites.rootdomain.com )

Software

  • Install Wordpress MU under sites.rootdomain.com

Command line work

For each of the following domains otherdomain1.com and otherdomain2.com

ln otherdomain1.com webroot directory to sites.rootdomain.com webroot directory
  $> cd /var/www/vhosts/otherdomain1.com
  $> ln -s /var/www/vhosts/rootdomain/subdomains/sites/httpdocs httpdocs

Now link the od1.sites.rootdomain.com to sites.rootdomain.com

ln od1.sites.rootdomain webroot directory to sites.rootdomain.com webroot directory
  $> cd /var/www/vhosts/rootdomain/subdomains/od1.sites/
  $> ln -s /var/www/vhosts/rootdomain/subdomains/sites/httpdocs httpdocs

Configuring Apache

To get Apache to follow the links that were setup above, under my Plesk install, I added the following rules to /etc/apache2/conf.d/subdomain.conf

<Directory  /var/www/vhosts/rootdomain.com/subdomains/od1.sites/>
   Options Indexes ExecCGI +FollowSymLinks MultiViews
</Directory>

<Directory  /var/www/vhosts/otherdomain1.com/>
   Options Indexes ExecCGI +FollowSymLinks MultiViews
</Directory>

Restart Apache.

Configure domains in Wordpress

Login to your Wordpress install @ http://sites.rootdomain.com/wp-admin/ and for each of the other domains create a blog of the same name as the subdomain created, so for otherdomain1.com create a blog called od1. When the domain is created go to its backend admin. Click the Domain Mapping link under Tools. Leave the ‘Server IP Address:’ box blank and just enter otherdomain1.com in the ‘Add new domain’ box. Do this for otherdomain2 blog

You should now be able to vistit http://otherdomain1.com and you will see Wordpress MU

Conclusion

The above seems a bit complex but once its done its done and it gets easier to each domain added. I have noticed some logout / edit issues for non-admin users under the above setup, I have not tracked down a reason for this yet, but stumbled upon a fix that I have to try and reproduce.

You might also run into problems say certain plugins, for example I use MapPress plugin which requires an API key. I have to generate 2 keys one for otherdomain1.com and od1.sites.rootdomain.com. I ended up hardcoding one key ( for otherdomain1.com ) in the plugin php file and entering one key in MapPress plugin admin options.

Extra Note(s)

2009-09-30:

1. WordPress MU could be installed in webroot/ for rootdomain.com rather than in a seperate subdomain. ( Just make sure you update the otherdomains to link to the new location. )

2. Make sure you setup WordPress to install blogs as subdomains and not in seperate paths

Hope this helps.

Full kudos to @jkeyes (http://keyes.ie) we had great fun working on the above.

Responses

  1. John O'Shea says:

    September 30th, 2009 at 7:10 pm (#)

    Thanks Geariod!