virtual server web hosting

The Apache web server can look at the language preference specified by a browser client and return file content depending on that preference. This ability, termed "language content negotiation," is a powerful feature of the Apache server that is seldom used.

You can use two methods of content negotiation. The first method relies on a "variants" file (var) that lists document resource files by file and identifies them with a specific language. This is convenient for small web sites, or if you only want to provide language specifications for the entry page of a web site. You could explicitly link from that page to web content authored in different languages. The second method uses file extensions (just like MIME types) to associate a file with a language.

Configuring Language-Content Negotiation by File Extension
  1. In your httpd.conf file, add language type definitions.
  2. From your ~/www/conf directory, edit your configuration file (httpd.conf).
  3. Add language definitions with the AddLanguage directive. For example:

    AddLanguage en .en
    AddLanguage es .es
    AddLanguage fr .fr
    AddLanguage de .de
    AddLanguage it .it
    AddLanguage jp .jp

The httpd.conf file associates the following file extensions with corresponding language abbreviations:

.en en English
.es es Spanish
.fr fr French
.de de German
.it it Italian
.jp jp Japanese

Note: The abbreviations are pre-defined and can be located in any of the latest generations of browser clients. For example, in Netscape 4.x, access associations in Edit/Preferences/Navigator/Language. Click the Add button. In MSIE 4.x, access associations in View/Internet Options/General. Click the Languages button. Click the Add button.

The language priority directive allows you to give precedence to some languages in case of the following:

  • A tie during content negotiation
  • The browser client does not specify a language priority (older browsers)
  1. List the languages in decreasing order of preference, as shown in the following example:

LanguagePriority en es fr de

Note: To use the LanguagePriority directive, load the mod_negotiation module. For more information, see the LoadModule directive section earlier in this Handbook.

  1. Modify the Options definition for your htdocs area to include MultiViews.
Including Multiviews
  1. From your ~/www/conf directory, open and modify your web server's configuration file (httpd.conf).
  2. Add MultiViews to the Options directive (part of your htdocs directory definition). For example, your Options line may look something like this:

    <Directory /usr/local/etc/httpd/htdocs>
    Options Indexes FollowSymLinks MultiViews
    </Directory>

Note: You can add the MultiViews to the Options definition in local access control files.

After you made these modifications to your web server configuration files, you can create content and upload it to your Virtual Server using different filename extensions. For example, instead of just creating index.php, create the following:

index.php.en
index.php.es
index.php.fr

When the browser client requests index.php, the server analyzes the browser client language preference and serves the appropriate index.php.* file to the user.

There is one exception to language preference. If the language preference the browser submits does not match any of the type definitions on your server and documents, the server returns a 406 error. This error means that the resource was found, but it could not be delivered because of incompatible resource types between the client and the server. For example, if a client only accepts Greek content (el), but you have only authored content in English, Spanish, and German, the client receives a 406 error. One workaround for this situation is to trap 406 errors with a custom ErrorDocument page or script.

Hosting  ::  Web Design  :: Server Administration  ::  Tech Support  ::  Contacts
Data Centers  ::  Tier I Global IP Network  ::  SLA/Contracts  ::  Search  ::  Account Login