Joomla installation on a subdomain: website in simplified chinese and in traditional chinese
Facts - Other software technologies
Monday, 15 June 2009 09:35

I had a website translated to both traditional and simplified chinese. The website in simplified chinese is www.jisuan.asia. The website in traditional chinese is traditional.jisuan.asia.

As you can see from the two url's, the website written in simplified chinese is installed in the default domain jisuan.asia and the website in traditional chinese is installed in a subdomain "traditional". This is convenient and easy to remember for internet users. However the problem was to install both websites under the same hosting account. I guess this is a common problem when you have a chinese website with an extra version in traditional chinese.

First I realized that the traditional website should be installed in a subdirectory of the main website. Some kind of clever url redirecting should then redirect all requests for the traditional subdomain traditional.jisuan.asia to this subdirectory. As a result the url's in link tags and src attributes of images and javascript files within the traditional website don't need to contain a subdirectory "traditional".

Here is how I accomplished this, first on the server and then on a local version of both websites running at my desktop:

Server side subdomain configuation

On the server side my hosting company provides Direct Admin to do website administration tasks. I did the following to get the website in traditional chinese running:

  1. Within the installation directory of www.jisuan.asia I made a subdirectory "traditional".
  2. I installed the traditional chinese website with joomla 1.5 inside this subdirectory.
  3. I set the live_site parameter in the file traditional/configuration.php to 'http://traditional.jisuan.asia'. This turned out to be necessary for the backend functionality.
  4. I created a subdomain "traditional" in Direct Admin.
  5. Upload a robots.txt in the root directory and in the traditional subdirectory. The two files can be identical. The robots.txt in the root directory has a line "Disallow: /traditional/". This prevents internet users from finding the traditional website with the wrong url. In this case the traditional website should not be found as www.jisuan.asia/traditional.

Sandbox subdomain configuation

I did the following to get the local equivalent of the simplified and traditional chinese websites running under Apache on my desktop (Windows, Apache 2.2.6).

  1. Within the installation directory of localjisuan.asia I made a subdirectory "traditional".
  2. I installed the traditional chinese website with joomla 1.5 inside this subdirectory.
  3. Again just as on the server I set the live_site parameter in the file traditional/configuration.php to 'http://traditional.localjisuan.asia'.
  4. I added the following to my host file: "127.0.0.1 traditional.localjisuan.asia", in addition to "127.0.0.1 localjisuan.asia". This redirects all traffic for http://traditional.localjisuan.asia and http://localjisuan.asia to my local webserver.
  5. I added to the virtual host configuation for localjisuan.asia in my local apache 2 webserver configuration file http-vhost.conf the following: "ServerAlias *.localjisuan.asia". This redirects traffic for all subdomains to the root folder of localjisuan.asia.
  6. I added the following lines to my local file ".htaccess" in the root folder of localjisuan.asia, before the SEF configuation for Joomla:
    RewriteRule ^\.htaccess$ - [F]
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteCond %{HTTP_HOST} ^([^.]+)\.localjisuan\.asia
    RewriteCond $1 !^traditional
    RewriteRule (.*) /traditional/$1 [L] 
    These lines redirect any trafic for traditional.localjisuan.asia to the subdirectory "traditional" created in the first step.

I tried different URL rewriting schemes: this one above is simple and does not break the Joomla SEF URL's.

Note that the local configuration involves a few extra steps compared to the configuration on the server. This is because DirectAdmin seems to take care of several steps when creating the subdomain. The local step of editing the host file is equivalent to adding a DNS A record on the server that points "traditional" to the server's IP address. The ServerAlias step is probably a default setting at my hosting company. If both URL's http://yourdomain.com and http://www.yourdomain.com work then this is likely to be the case with you hosting provider as well.

On a virtual linux machine the redirect did not works with a later version of Apache than 2.2.6. So on this machine I created virtual hosts for each subdomain. For me this is the best solution anyway.

Last Updated on Sunday, 06 December 2009 21:02