Some of you may know that Imagewize Webdesign, run by me, is a site that runs on two languages from two different domains – Dutch and English. This is done using the nifty plugin WPML. With it you can manage your content in multiple languages. You can also run all content from one location and still serve it on separate (sub) domains! To make this work you do need to set things up properly in the backend and server wise. Here is how.

WPML – Intro

WPML is the best multilingual Content Management Plugin out there for WordPress. I do use qTranslate X, but it simply cannot compete with the options WPML offers and certainly cannot offer the stability WPML has to offer. qTranslate has gone through several reincarnations over the past couple of years and has been buggy at times. WPML works well out of the box, deals with:

It does it all and no extra plugins are needed. Nice!

Now let’s get back to the cool feature of WPML – Two Languages – Two Domains – One CMS

Server Side

On the Apache webserver – NGinx not covered – you need to make sure that all traffic going to the domain that is not running the content is redirected to the main domain location or vhost. This can be done using a ServerAlias. WPML Example here below:

<VirtualHost *>
  DocumentRoot /your_wp_install_directory/wordpress
  ServerName www.english-domain.com
  ServerAlias www.french-domain.fr

  ... your other stuff here ...
</VirtualHost>

So for Imagewize we needed:

<VirtualHost xxx.xxx.xxx.xx:80>
ServerAdmin webmaster@imagewize.nl
DocumentRoot /home/wp_zzsk4g/imagewize.com
ServerName www.imagewize.nl
ServerAlias imagewize.nl

As you see Dreamhost added the ip address and port. Inside that vHost the DocumentRoot was added with a ServerName and ServerAlias imagewize.nl to redirect all traffic from that domain to imagewize.com.

The basic Domain name mirroring that is supposed to work as a ServerAlias with Dreamhost just did not do the trick. I assume it was only adding a ServerAlias and not a DocumentRoot to load data from one location. But I am glad Dreamhost helped me out in the end and set this up on my Dreamhost Managed VPS!

Client side

Client side you need to configure WPML – dashboard > WPML > languages > language url format – to load the content of the main language from domain a and for the secondary language from domain b.

WPML - Two Languages - Two Domains - One CMS

WPML will validate the domains added to make sure they are correct and all works.

Any question, comments? Please let me know in the comments!

 

Update

Dreamhost VPS no longer allows adjusting httpd.conf or adding vhosts – no sudo access anymore. The mirroring of the domain nor the chaning the DocumentRoot to make imagewize.nl load data from imagewize.com for WordPress with WPML worked as a new solution. So I had to use the second language in a subdirectory and redirect the second domain traffic there using a redirect in the .htaccess:

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^imagewize.nl$ [OR]
#RewriteCond %{HTTP_HOST} ^imagewize.com.com$
RewriteRule (.*)$ https://wpvilla.in/nl/$1 [R=301,L]
</IfModule>

The only other solution would be to move to a dedicated or cloud environment. Looking into these options, but will stick to this VPS for now though I have issues with spikes in RAM due to scripts I am running every now and then for security and backups.

Leave a Reply

Your email address will not be published. Required fields are marked *