Subdomain Based Multilingual WordPress

Some days ago I wrote I was trying to setup this bilingual blog using different database tables but the same WordPress installation. This way I only have to upgrade my WordPress installation and plugins once. But I can still use different themes / language per subdomain if I want to do so.(and that’s great for experimenting).

Having this done is pretty easy. You have to change the part where you define your table_prefix in your config.php file to something similar to the code below.


$subdomain = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], '.'));
if ($subdomain == 'en')
{
$table_prefix = 'en_';
}
else
{
$table_prefix = 'wp_';
}

In this case I presume you want to link the subdomain ‘en’ to $talbe_prefix = ‘en_’ like I did for this website. If you want to use ‘english’ as a subdomain and you used ‘wp2_’ as table_prefix, of course you’ll have to use those values.

Now I only need to find a plugin that is able to scan the wp_content/uploads/ directory so I can use the same media in both blogs.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.