Search code examples
webinternationalizationwebserver

Possibility of having multiple domains pointing to one multilingual website


Being new in the world of creating websites, I was wondering if it could be possible to create a website with its language based on the domain extension.

Explanation: I have a two domains being domainname.com and domainname.de. I have a single server representing domainname.com, and have domainname.de pointing to the same IP as domainname.com.

Now, I want my customers to be shown the English site when they visit domainname.com, and have them shown the German site when they visit domainname.de.

What are the best options to do so?

I have searched the net for options, but I do not prefer them;

  • domainname.com/de/ is just ugly.
  • de.domainname.com is unclear and makes domainname.de unnecessary.
  • domainname.com with a button translating all the text to German for both reasons stated above.

Is it an option to let HTML/CSS check the domain extension and load .html files based on that? Or should I write PHP scripts to do so?

My main requirement is to keep the URL as short as possible. I am also not able to get another server.


Solution

  • The answer I found was using virtual hosts.

    It is easily done by editing the httpd-vhosts.conf file by just adding

        <VirtualHost *:80>
            DocumentRoot "C:/www/de
            ServerName www.domainname.de
            <Directory "C:/www/de">
                Options Indexes FollowSymLinks Includes ExecCGI
                Order allow,deny
                Allow from all
            </Directory>
        </VirtualHost>
        <VirtualHost *:80>
            DocumentRoot "C:/www/com
            ServerName www.domainname.com
            <Directory "C:/www/com">
                Options Indexes FollowSymLinks Includes ExecCGI
                Order allow,deny
                Allow from all
            </Directory>
        </VirtualHost>
    

    And thereafter put the HTML/CSS and PHP files in the right path.