WordPress MU Domain Mapping is a popular plugin, which allows running multiple, independent sites (each with its own domain), from a single Network-enabled WordPress install. We’ll explain how to use WordPress MU Domain Mapping with WPML.
Configuration
- WordPress
- WordPress MU Domain Mapping 0.5.5+
- WPML, configured with languages in directories
- WPML MU Domain Mapping Plugin
Our demo network consists of these sites:
- tenalpa.com – main site
- subsite1.wpml.org / blog1.tenalpa.com
- subsite3.wp-types.com / blog2.tenalpa.com
- subsite2.icanlocalize.com / blog3.tenalpa.com
If you’re not familiar with WordPress MU Domain Mapping, the way it works is by mirroring subdomains, which WordPress assigns in Network mode, to completely independent domain. In our example, the native subdomains are blog1-3.tenalpa.com. It maps them to subsite1.wpml.org, subsite3.wp-types.com and subsite2.icanlocalize.com.
You can control this mapping from the WordPress MU Domain Mapping admin screen:
Network Admin->Setting->Domain Mapping
Setup Steps
Most of these steps are not related to WPML. In fact, WPML doesn’t really care much about the WordPress MU Domain Mapping plugin. It decodes the domain and WPML looks at the URL for each page. We’re including here the full list of steps, so that it serves as a complete guide.
Point all sub-sites to the same WordPress install
You need to tell Apache (or whatever web server you’re using) to point all domains to the same physical WordPress install. We do this using the DomainAlias instruction.
This is our Apache configuration file:
<VirtualHost 72.249.85.20:80> DocumentRoot OUR_SERVER_DIRECTORY/domain-mapping-test/wordpress ServerName domain-mapping-test.wpml.org ServerAlias subsite1.wpml.org ServerAlias subsite2.icanlocalize.com ServerAlias subsite3.wp-types.com <Directory OUR_SERVER_DIRECTORY/domain-mapping-test/wordpress> Options FollowSymLinks AllowOverride Limit Options FileInfo DirectoryIndex index.php </Directory> </VirtualHost>
Add the required directives to wp-config.php
The setup process, required to convert a single-site to a network site, will give you specific instructions. This is what we have:
define( 'MULTISITE', true ); define( 'SUBDOMAIN_INSTALL', true ); $base = '/'; define( 'DOMAIN_CURRENT_SITE', 'tenalpa.com' ); define( 'PATH_CURRENT_SITE', '/' ); define( 'SITE_ID_CURRENT_SITE', 1 ); define( 'BLOG_ID_CURRENT_SITE', 1 ); define( 'SUNRISE', 'on' );
Add the required directives to .htaccess
Again, you’ll get specific instructions for your site. This is what we’ve added to .htaccess:
RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule . index.php [L]
Settings in WordPress Admin
Finally, you need to configure the WordPress MU Domain Mapping plugin and WPML.
In WPML, the only required setting is in WPML->Languages. Select ‘Languages in directories’. When you use WordPress MU Domain Mapping, you cannot also have languages in domains.
When enabling Multisite, we choose to have different child sites in subdomains.
- IP address users need to point DNS A records or the domain to paoint CNAME record at 72.249.85.20 (happens to be our IP address)
- Domain Options (I left these to default settings as below)
- Remote Login Checked
- Permanent redirect (better for your blogger’s pagerank) Not Checked
- User domain mapping page Checked
- Redirect administration pages to site’s original domain (remote login disabled if this redirect is disabled) Checked
- Disable primary domain check. Sites will not redirect to one domain name. May cause duplicate content issues. Not Checked
The results
As you can see, all child sites perform normally.
For instance:
- http://subsite1.wpml.org/2011/12/15/english-post-2-in-english-cat-2/
- http://subsite1.wpml.org/fr/2011/12/15/french-post2-in-french-cat-2/
- http://subsite2.icanlocalize.com/2011/12/16/sample-english-post-1-in-cat-1/
- http://subsite2.icanlocalize.com/sv/2011/12/16/sample-swidish-post-1-in-swidish-cat1/
If you need help getting WordPress MU Domain Mapping to work with WPML for your own site, please start a new thread in our technical support forum.
WPML MU Domain Mapping Plugin
WPML development team detected a problem on the language switcher for secondary languages, when using the WordPress MU Domain Mapping plugin. To resolve the issue, we developed a bridge plugin. It does not add any pages or options to the WordPress admin but it resolves all issues related to the language switcher.
All you need to do is download our WPML-MU-Domain-Mapping and install it just like any other WPML plugin.