contact us

Use the form on the right to contact us.

You can edit the text in this area, and change where the contact form on the right submits to, by entering edit mode using the modes on the bottom right.


London
UK

I build things on the Internet. DJ - Producer, Sound engineer, music lover and a general full-time geek! Riding through this world... Made in Italy.

Blog

Just another way to show what I'm doing... my Design, my Music, my Development.

Domain Mapping for Wordpress Multisite without any plugin

Joe Maffia

So... I'm not going through the whole process of setting up a Multisite Network in Wordpress; they do a pretty good job already in documenting the whole steps http://codex.wordpress.org/Create_A_Network The issue though was to domain mapping each single site to a different domain. In my case was a localised domain with a path in it! (jus to make the whole setup bit more fun).

The famous plugin to accomplish this all from the Wordpress admin panel is http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/ but unfortunately since the new 3.5 release is having some problems. So here's how I did the mapping changing stuff directly into the DB and with a quick mod in the .htaccess

The idea behind is that of course you have full access to the server (at least SSH) and to the DNS bits. (each domain is pointing to the same wordpress installation)

My scenario:

www.example.com (main website not on wordpress)

www.example.com/blog/ (wordpress multisite)

www.example.fr/blog/ (wordpress multisite)

www.example.de/blog/ (wordpress multisite)


etc.

The first issue with the plugin was that it does domain mapping only with the :domain" itself: example.fr or example.de not of course with a path like exampl.fr/blog/

So the way I setup the whole thing...

blogs.example.com is pointing to the wordpress installation and from here I do the whole setup and activate Multisite. (in this way I can enable the Sub-domains option— a domain-based network in which on-demand sites use subdomains). Once that is done, you should be able to have something like:

site1.blogs.example.com

site2.blogs.example.com

etc.

if everything is up and running fine the next step is the mapping itself. Now as you may know Wordpress has two concept for URL:

  • The "Home" setting is the address you want people to type in their browser to reach your WordPress blog.
  • The "Site URL" setting is the address where your WordPress core files reside.

Login into your db and change these values. The Multisite installation create lots more table than the standard one, in the specific for each site you should have something like: wp_1_options, wp_2_options and so on... in here change the value for siteurl and home to be what u wish. (in my case the value are www.example.fr/blog - no trailing slash!)

Also you have to change the wp_blogs table, in the specific the domain and path value. (again in my case domain= www.example.fr, path=/blog)

Once you done that, you should have all the different sites under their own domains. But there's one last step...

The Admin panel won't work :)

That's 'cause in your wp-config.php once you had the Multisite active, will look like:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'blogs.example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

 

You have to change this line define('DOMAIN_CURRENT_SITE', 'blogs.example.com'); and set the value to

define('DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST']);

Last but not least what the .htaccess looks like:

# BEGIN WordPress 
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress