mod_rewrite-free MIME type switcheroo

Thursday, 24 Jun 2004

I made another attempt at correcting my MIME type situation (I was serving XHTML 1.1 with a MIME type of text/html, which is wrong). There is a mod_rewrite based solution out there, but mod_rewrite is a sledgehammer, and I thought this should be possible with a lighter tool. Indeed it is:

<FilesMatch "\.s?x?html$">
  SetEnvIf Accept application/xhtml\+xml            ACCEPT_XHTML
  SetEnvIf Accept application/xhtml\+xml\s*;\s*q=0 !ACCEPT_XHTML
  SetEnvIf Request_Protocol HTTP/(0\.|1\.0)        !ACCEPT_XHTML
  Header set Content-Type "application/xhtml+xml; charset=iso-8859-15" env=ACCEPT_XHTML

Unfortunately I currently can’t use this for lack of mod_headers on this server.

Right now, I’m serving my XHTML files as application/xhtml+xml to everyone, including Internet Explorer, which breaks with this MIME type. Sigh.