So, you want to have a WPML site with the different domain per language option?
There are some nice advantages of using different domains in your site that go well beyond appearances.

Some people prefer to access a domain name that looks to belong to their own country and this can create a loyalty in your visitors. There is a kind of SEO bonus as well, because you can use the domains to better target your users.

Different domains per language are setup on the WPML -> Languages page.

Different domains per language are setup on the WPML -> Languages page.

 

First, let’s explain what this exactly means when used in practice.

If for example, you want to have English and German languages with WPML and different domain per language option.

You have two options when setting up per-domain languages:

  • Different domains

If, for example, you have two domains – example.com for your English language, and example.de for your German language, by using that option you can achieve that.
example.com > English
example.de > German

  • Sub-domains

You can also use sub-domains- like in example: en.example.com – for your English language and de.example.com for your German language.
en.example.com > English
de.example.com > German

So, the next big question is how you can achieve that. The answer depends on two main components of your site’s setup:

  • Your DNS server
  • Your HTTP server (Apache, Nginx, etc.)

Setting up your DNS server

Manual setup

DNS settings with top level domains setup

If you have different top level domains (example.com, example.de), you first need to configure them to have the proper authoritative DNS servers. This is usually done in the settings panel provided by the company that you bought your domain from.

When you have added the domain, you need to create a record in your DNS server, that points to your HTTP server. Simply put, server needs to know what data to provide your users with, once they are on a specific domain. If they reach the .de domain, you want server to show them the German version of your site.

If you have your own DNS server, you can (and it is best to) create an “A Record” for your other domain that points to your server.

There are two different records that you can use.

  • A record – you specify the IP of your server – this is a good and fast solution
  • CNAME record – you specify domain name for your server – a little bit slow, but good if you change the server IP addresses often
List of records. Your screens for configuring top level domains may differ.

List of records. Your screens for configuring top level domains may differ.

DNS settings with sub-domains setup

The setup for sub-domains is easy! You just create an additional A or CNAME record in your DNS server and point it to the same HTTP / HTTPS server IP or domain.

Your screens for configuring subdomains may differ

Your screens for configuring subdomains may differ

Please note that after you complete this settings, you need to continue with the “Setting up your HTTP server” part of this guide.

cPanel setup

Using Cpanel automatically adds the necessary DNS and HTTP entries, so you need to do only this in order to prepare your server.
Setting up top level domain
In most cases the part of your cpanel that you need to use, looks like this.

domains.cpanel

You can use two kind of methods to add your additional domain:

  • Parked domain – to park the additional domain name – this is the best option, since it uses the same path for your site in the http settings.Parked domain screen
  • Addon domain – you must be careful to specify the folder with your current WordPress installAdd-on domain screen

Having done that, you can now go to “Wrapping things up” part of this guide.
All settings for your Apache and DNS will be created and added by Cpanel and everything should work.

Setting up the subdomains

To use a subdomain setup, you need to select the subdomains icon from the Cpanel menu.
When creating a subdomain you have to point it to where your WordPress has been installed before in order to work with “Different domain per language” option in WPML.Subdomains screen

Having done that, you can now go to “Wrapping things up” part of this guide.
All settings for your Apache and DNS will be created and added by Cpanel and everything should work.

Make sure that all domains point to the same root WordPress folder after double-checking the configuration.

Setting up your HTTP server

Okay, so we come to the second most important part of the setup, when you are using a server that you can manage.

In order for your settings to work, you need to create an entry in your web server that will recognize the domain name (or the sub-domain name) that you have just added and pointed to in your DNS server.

If you are running and administrating your own server, it is pretty easy – you just need to add server alias to your current configuration.

Following is an example used for the Apache server setup.

 DocumentRoot "/var/www/www.example.com/webroot"
  ServerName example.com
  ServerAlias example.de
...

That’s all to add – easy, right?
It is similarly easy to setup this up on the Nginx server.

server {
        server_name example.com;
        ...
}
 
server {
        server_name example.de;
        ...

Whichever route you choose, the most important thing to consider is that the alias configuration should all point to the same physical folder where your WordPress is being installed.

Wrapping things up

When you have all this set up you can change the settings on the WPML -> Languages to Different domain per language. When you fill out the information required (the other domain or subdomain), pressing the Save button should validate your domain. It will report if there are any problems with the validation, and then save all the settings that you have made.

Debugging

If you still have problems with the new setup it is best to enable debugging in WordPress. You can do this by adding the following snippet to your WordPress site’s wp-config.php file.

// Turn debugging on
define('WP_DEBUG', true);

// Tell WordPress to log everything to /wp-content/debug.log
define('WP_DEBUG_LOG', true);

// Turn off the display of error messages on your site
define('WP_DEBUG_DISPLAY', false);

// For good measure, you can also add the follow code, which will hide errors from being displayed on-screen
@ini_set('display_errors', 0);

Then you need to monitor the log file that will be created in /wp-content/debug.log when you save the domain options in WPML.

You can also monitor the admin-ajax.php response in your browser console (press F12 on your keyboard to show the console). Based on the console output and the log from ../wp-content/debug.log – you can disable non vital WordPress plugins to try and find the source of the problem.Browser console example

If you still have issues it is best to contact one of our specialists here in the WPML forums.


 

George Botsev

George Botsev

I am a geeky guy, that likes Star Trek, computers, and all other geeky stuff. My other interests are mainly related to IT, System Administration, Electronics, Open Source Software, Open Source Hardware, Photography, and Music.

I have more than 10 years experience with WordPress, and also about 10 years professional experience with IT and System Administration.

My main duty has always been to debug issues, and since September 2014, I joined the WPML Support team and I help some of you in the forums to resolve your problems.

3 Responses to “How to use WPML with different domains per language”

  1. It’s very a nice and useful piece off site.
    I amm glad tuat you
    shared this helpful information wijth us. Please keep
    us up to date like this. Thanks for sharing. jual bibit bunga

  2. philipC-5 says:

    Hi George,

    Thanks for putting this together. I am attempting to configure sub-domains for each language, and am having difficulty. In the setting up your HTTP server section you mention “t is pretty easy – you just need to add server alias to your current configuration.”

    Is this a file? How do we update this? My client is using Plesk, which can use both Apache and Nginx. I am not a developer/programmer, so more clear guidance would be appreciated.

    Thanks!
    Phil