Thursday, February 18, 2010

Content Negotiation Apache Style

Content Negotiation is a complex sounding term for what is really a simple process.

Imagine calling your doctor's office to make an appointment. You tell them what dates you prefer and they respond with the opening that best fits your preference.

The Wikipedia entry on content negotiation is kind of sparse but has links to the RFC and other information.

Apache can handle content negotiation and if the apache server is configured to allow it, you can turn on per directory Content Negotiation with an htaccess file.

Contents of .htaccess file

Options All +MultiViews


The permissions of the .htaccess file should be readable

-rw----r-- 1 owner group 24 2010-02-08 19:48 .htaccess


Apache instructions for Content Negotiation

Then you can put multiple files in the same directory with the same name.
e.g.
image.png
image.gif
image.jpeg

When a user requests the image like http://example.com/image the browser will negotiate with the server for the preferred image type.

No comments:

Post a Comment