Re: xhtml, htaccess and accept-headers
Okay, I've experimented a bit and actually found a way to do this with
mod_rewrite, which I'll put here in case someone else ever needs this.
It's really amazingly simple.
1. Files now have the .html extension again
2. The AddType declaration that sends application/xhtml+xml for .html
files is gone.
3. This rewrite rule adds the relevant content type:
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
RewriteCond %{REQUEST_FILENAME} \.html$
RewriteRule .* - [L,T=application/xhtml+xml]
This nicely works together with other rewrite rules that may already be
there. For example, I have one that allows the ".html" extension to be
removed from the URL - /about will return about.html:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [QSA]
That rule just needs to be added above the earlier one, and both will
work as intended.
--
Christoph Burschka
|