Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you force the <code>/xhtml+xml</code> header, then IE won't interpret your pages anymore. Which is why nobody actually bothers to do it correctly. (And the very reason I do it on another site.)</p> <p>It's however possible to let your webserver handle the sending of the correct MIME type. Normally you could let <a href="http://httpd.apache.org/docs/2.2/mod/mod_negotiation.html" rel="nofollow">mod_negotiation</a> handle that. However that requires having two versions of each document:</p> <pre><code>index.en.html index.en.xhtml </code></pre> <p>Then if a url/resource <code>/index</code> is requested, it will automatically determine the appropriate document version, and send it with the right media type. However, it doesn't really understand the type variance of the serialization formats, nor can you set a precedence. And holding out two files with the same content is not overly senseible to begin with.</p> <p>Therefore an easier approach would be to use mod_rewrite to handle the MIME type switching:</p> <pre><code>RewriteCond %{HTTP_ACCEPT} !application/xhtml\+xml RewriteRule .+\.xhtml$ - [T=text/html] </code></pre> <p>This will send the configured header for all .xhtml documents, but override that if the browser does not indicate XHTML support. That's not quite complete, because to avoid proxy issues you also need to set the Vary: header if you manually do any kind of content negotation. This requires mod_header:</p> <pre><code>RewriteRule .+\.xhtml$ - [E=VARY_XHTML:1] Header append Vary "Accept" env=VARY_XHTML </code></pre> <p>You can do the same with a PHP script wrapper, but then you lose all the benefits of having the server handle it. Either way, it's quite a bit of effort, which is why hardly anyone really does it. But if you really want the XML parsing errors, this might be a semi-workable option.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload