XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
[xml-dev] Can I serve one resource with two distinct MIME-types?

When it comes to deliver XHTML to various browsers, it seems that the
tutorial [1], written by Dominique Hazaël-Massieux,
"Content-Negotiation Techniques to serve XHTML 1.0 as text/html and
application/xhtml+xml" (2003), still represents the state of the art.

In a small paragraph, under the heading "Can I serve one resource with
two distinct MIME-types?", he wrote:
While it's theoretically possible, I don't know any way to do it
without breaking some important aspects of HTTP (such as proxying, or
the HTTP PUT method) - that is, the method I know using RewriteRules
doesn't set headers such as ETag as it should.

Because I did not fully understand the above, I tried to implement it
(.htaccess, Apache 1.3.32):

AddType application/xml .xml
AddType application/xhtml+xml .html
AddType application/xsl+xml .xsl

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} \.html$ [NC]
RewriteCond %{HTTP:Accept} !application/xhtml\+xml [OR]
RewriteCond %{HTTP:Accept} application/xhtml\+xml\s*;\s*q=0
RewriteRule .* - [T=text/html;charset=utf-8,L]

Be aware, because of a bug [2] you can't change anything else for the
URI selected. If you do, you will lose the MIME-type you want to
insert! To prevent this, I've added the L (last) parameter.

This works for me without problems! Some advantages:
- no renames necessary, thereby preserving the search engine index
- no content-negotiation, supports both HTTP1.0 and HTTP1.1.
- no duplicate content
- easy testing on a per directory basis

Manfred

[1] http://www.w3.org/2003/01/xhtml-mimetype/content-negotiation
[2] http://issues.apache.org/bugzilla/show_bug.cgi?id=36590

--------------------------------------
Manfred Staudinger
Vienna, Austria


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS