httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Meadors <>
Subject [users@httpd] Changing MIME-type with mod_rewrite
Date Sun, 01 Dec 2002 19:49:03 GMT
The W3C XHTML 1.1 spec says that XHTML 1.1 documents must be served with 
the MIME-type application/xhtml+xml.  All the .html files on my server 
are written to XHTML 1.1 specs, so I would just change the MIME-type of 
files with that extension.  But Internet Explorer decides that it should 
just save the file to disk instead of displaying it.

I've seen several sites talking about using RewriteRules to only change 
the type for UAs that "Accept" application/xhtml+xml.

The best rule I've seen so far comes from, it is:

RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
RewriteCond %{HTTP_ACCEPT} !application/xhtml\+xml\s*;\s*q=0
RewriteCond %{REQUEST_URI} \.html$
RewriteCond %{THE_REQUEST} HTTP/1\.1
RewriteRule .* - "[T=application/xhtml+xml; charset=utf-8]"

But it just doesn't seem to work.  One problem I see, it is looking for 
URIs ending in .html.  Most of my pages are index.html files and I just 
reference the directory.  But I did make a test .html file and it is 
still served with the default text/html type.

Also if I put those rules in the global server conf section, will they 
be applied to all virtual hosts too (I want them to be).

I'm using Apache 2.0.  Can anyone tell me what I'm doing wrong, and 
perhaps give me a better rule set?


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message