HTTP Content Negotiation for Language Selection

Assignment 1 — Web-Based Services (INFOSYS 290-3; Fall 2006)

Assigned: 2006-09-06 / Due: 2006-09-13

Author: Erik Wilde

Introduction: This assignment deals with the easiest Web-based service next to pure file retrieval: HTTP content negotiation. By configuring a Web server appropriately, users can be served with documents that match their language preference. This is much better than the usual please choose your language way of having the user answer this question for each Web site he is visiting.
Resources: Firefox Live HTTP Headers
HTTP Request Header Viewer
HTTP Response Header Viewer
Apache Content Negotiation
Apache .htaccess Files

The following steps are intended to encourage exploring the services implemented by a Web server. Apache is a highly configurable piece of software, and we will only look at a part of one of the many functions it provides. When completing the following steps, read a bit more of the documentation than you absolutely need and explore some more of Apache's features!

  1. HTTP Headers: Explore what your browsers sends as HTTP request headers and what you get from your favorite Web site as HTTP response headers. Try to understand all HTTP Headers in both types of messages, and change your browser's configuration in a way which changes the HTTP request headers it is sending. This is most easily done by changing you language preference, which also sets you up for the following steps.
  2. Multiple Home Pages: In your iSchool Web space at (here's the FAQ about how to use it), create two files for your home page in two languages, one being english, the other one a language of your choice (). We are interested in the HTTP server mechanics, so keep these home pages short (such as saying this is my english page)! At this step, the language is not visible to the server, these are simply two Web pages.
  3. Setting up Content Negotiation: We now use Apache's content negotiation to let the server choose the best representation of your home page, based on the language preference sent by the browser in the Accept-Language header. This involves two things: (a) set up content negotiation using Apaches Multiviews feature, which you have to request explicitly in an .htaccess file in your Web space's directory; after doing this, (b) rename the two home pages appropriately so that the Multiviews feature works. For this second step, you need to find out the magic way of how files need to be named for Apache, which involves using file extensions... After renaming the files, you're finished, your browser's language preference now actually selects the home page in your preferred language!
  4. Fallback: But what happens if a user requests a language which is not provided by the server? To find out, rename both your language-specific home page files to obscure languages (such as italian and french) not requested by your browser (or do it the other way around: change your browser's language preference to a language other than the ones you are providing). Using the configuration used so far, the browser now returns the language with the language code which comes first in the alphabet. This is not really useful! Take care of this by defining reasonable LanguagePriority values for your example in your .htaccess file.
  5. No Default: Language priorities have two purposes: resolving a tie when two languages could be served, and selecting a language when no language can be served. Now let us assume you don't want to force your preferred language to someone requesting something you don't have available. Add ForceLanguagePriority Prefer to your .htaccess. What happens? Does this look user-friendly?
  6. Assignment: Come up with some suggestions how you would design a multi-lingual Web site which (a) uses server-side content negotiation, (b) resolves ambiguities in case a user requests more than one provided language, and (c) does not force users to see a language they haven't selected (or does so only in a friendly way). (a) and (b) are simply repetitions, for (c) i would like to see something more creative than let them see Apache's Not Acceptable page.

If you have questions, feel free to send me an email or come and visit me. Please send (a), (b), and (c) to me by email, being as terse as possible without omitting necessary details. Thanks!

please send comments to
last modification on Friday, 02-Mar-2007 19:39:32 CET
valid CSS! valid XHTML 1.0!