Problems with CSS generated using PHP and Internet Explorer 9

CSS, PHP, Internet Explorer

Josep Sanz

After a few months to be with us the new Microsoft browser, Mr. Internet Explorer 9, some visitors saltos.net informed me that the web did not look properly using this browser.

After watching what was happening, detected from the apache logs that requests for style sheets that make Internet Explorer 9, were answered by the apache server itself with an error HTTP 406 Not acceptable (not acceptable).

This portal is developed using the RhinOS technology, which generates PHP style sheets from templates. This means that in reality the CSS request is made, even if they are made to a static .css file, is served by a PHP script that will intercept the request to consider and respond with the contents of the CSS and headers corresponding with the content-type "text/css".

As the new browser sends the header "Accept: text/css" only instead of what everyone does it "Accept: text/css; */*", the apache server does not process with php the request and not finding a way to resolve it, send the error 406.

To fix this problem, simply add in the .htaccess file the follow line: "AddType text/css .php". With this entry in the .htaccess file, the server may relate the requests to a .php with Accept "text/css", so that everything will work as usual.

If the server has disabled the .htaccess overload feature, RhinOS provides another method that is to use an alternative url that solves the problem. To do this, simply add the tag in the CSS file path. Automatically, detects the IE9 client and the new url is published to serve the content without generating the 406 error.

Thanks Microsoft for making things easier!!!

XML lines
PHP lines
JS lines
T2T lines
XSLT lines
SQL lines