Hey folks,
I like to use qTranslate for my multilingual websites. Today I had to set up a different language for each domain pointing on my WordPress installation. Here’s what was the simplest solution.
First, in your administration panel, in Settings > Languages, in Advanced Settings > URL Modification Mode, make sure you Use Pre-Path Mode.
Then, in your .htaccess (which shall be around your root directory), above the Rewrite Rules, redirect each one of those pre-paths to the wanted domain.
RedirectMatch 301 /fr/(.*) http://www.francais.fr/$1 RedirectMatch 301 /en/(.*) http://www.english.co.uk/$1
Too easy. Now in your theme’s functions.php file, configure qTranslate’s language settings according to the current domain. Let’s reset WordPress URLs as well, so it always link to the current domain.
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] );
$current_domain_lang = array_search( str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ), array(
'fr' => 'francais.fr',
'en' => 'english.co.uk'
) );
$q_config['language'] = $current_domain_lang;
$q_config['default_language'] = $current_domain_lang;
Should work like a charm… tell me if you notice an issue though.