The Tridecadal Korean (astralblue) wrote,
The Tridecadal Korean
astralblue

Apache Tip: IE+“application/xhtml+xml”=T_T

If your site has a bunch of .xhtml files which choke IE 'cause Apache serves 'em under application/xhtml+xml:

RewriteCond %{REQUEST_URI} !\.xhtml$
RewriteRule ^ - [skip=2]

RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
RewriteCond %{HTTP_ACCEPT} !application/xhtml\+xml\s*;\s*q=0
RewriteRule ^ - [skip=1]

RewriteRule ^ - [type=text/html]

Basically that means: If the filename extension is .xhtml and the HTTP Accept: header either doesn't have application/xhtml+xml defined or has it defined but with quality of zero (meaning: I refuse the type), override its MIME type and return it as text/html.  This uses the fact that Mozilla/Firefox explicitly includes application/xhtml+xml in the Accept: header of each and every HTTP request while IE does not.

Note: If you have .xhtml defined in DirectoryIndex and want the above snippet to work for the directory URLs as well, it must be defined in the main httpd.conf; defining it in .htaccess does not work for an obscure reason that involves Apache's internal subquery processing.

Tags: apache, ie, internet explorer, xhtml
Subscribe

  • Stolen from darksakura

    Superhero Team Quiz LiveJournal Username Your Primary Super Power Energy Control (ex. Fire, Cold, Electricity, etc) High Tech Devices…

  • Boom.

    ル-ル 규칙. Rules. 見たらやる。 보면 한다. Simple. You see this, you do this. 地雷バトンです。 지뢰바톤입니다. Because this is a landmine meme. 見たらスグやるバトン←コレ重要! 보면…

  • At least I didn't fall down to two digits… XD

    Stolen from zqfmbg. 108 words free Touch typing

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 3 comments