|
[ Order a Server ] [ Server Support ] |
|
[ Getting Started ] [ Server Help ] [ Add on Help ] [ Solution ] [ Trouble Shooting ] PLEASE NOTE, THIS IS VERY OLD ARCHIVE INFORMATION AND MAY NOT FUNCTION ON NEW SERVERS
Serving Documents Based on Language PreferenceThe Apache Web Server has the ability to look at the language preference specified by a browser client and return the content of different files depending on that preference. This ability, termed "language content negotiation", is a simple yet very powerful feature of the Apache server that is not often used.There are essentially two approaches to content negotiation. The first uses a "variants" file (or a "var" file) which essentially lists document resources file by file and identifies them with a specific language. This may be convenient for small sites or if you only want to provide language typing for an entry page of a web site (which would then explicitly link to web content authored in different languages). The second approach uses file extensions (just like MIME types) to associate a file with a language. Please find below a list of the steps necessary to configure the web services on your Virtual Server to perform language content negotiation by file extension. More information about configuring language content negotiation on a file by file basis can be found by reading the reference documents included at the bottom of this page.
Using whatever method you find convenient, edit
the ~/www/conf/httpd.conf
on your Virtual Server
or the ~/www/conf/srm.conf file, if you Virtual Server was configured
before Dec. 8, 1998) and
add language definitions using the
Basically, this will associate the file extensions, .en .es .fr .de .it .jp, with the corresponding language abbreviations, en es fr de it and jp. The abbreviations are pre-defined and can be located in any of the latest generations of browser clients. For example, in Netscape 4.x they are found in "Edit->Preferences->Navigator->Language->Add(button)". In MSIE 4.x they are found in "View->Internet Options->General(tab)->Languages(button)->Add(button)".
Using whatever method you find convenient, edit
the ~/www/conf/httpd.conf file
on your Virtual Server
(or the ~/www/conf/srm.conf file, if you Virtual Server was configured
before Dec. 8, 1998) and
and add a language priority definition using the
The language priority directive allows you to give precedence to some languages in case of a "tie" during content negotiation or if the browser client does not specify a language priority (older browsers). Just list the languages in decreasing order of preference.
Using whatever method you find convenient, edit the file
The "MultiViews" option can also be added to the "Options" definition in .htaccess files.
That's it! Now you will need to author content and upload it to your Virtual Server using appropriate extensions. For example, you would create "index.html.en", "index.html.es", "index.html.fr", etc. instead of an "index.html". When the browser client requests "index.html", the server will analyze the language preference of the browser client and serve the appropriate "index.html.*" file seamlessly and transparently.
There is at least one snag. If the language preference the
browser submits does match any of the type definitions on your server
and documents you have authored.
The server will return a 406 error (i.e. the resource was found, but
could not be delivered because the type of the resource is incompatible
with the acceptable types indicated by the
ReferencesContent Negotiation Explained (Apache Week Feature)
PLEASE NOTE, THIS IS OLD ARCHIVE INFORMATION AND MAY NOT FUNCTION ON NEW SERVERS |