Force Correct content-type for XHTML Documents

Avatar of Chris Coyier
Chris Coyier on

Most webservers serve XHTML content as text/html what is definitly the right way to handle XHTML documents. In case the server isn’t doing that correctly, you can force it on Apache servers with .htaccess:

RewriteEngine On
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=ISO-8859-1]"