Resolution of a CSS styling issue running PHP5 on IIS
A small piece of development work that we completed for a client in December 2007 threw up an unexpected problem.
We developed a small PHP based application to enable staff to easily import and validate data from a Lotus Notes system through an administration console, while at the same time enabling the public to easily search and view the same data.
Things were slightly complicated by the fact that the application was to seamlessly integrate with an existing ASP.Net CMS application – particularly with regard to the overall look and feel. the illusion to be created was of one system.
It would not be the first time that PHP has been asked to co-exist on an IIS server. We did our research, developed the system, did test installations on a QA box – and were happy with the upgrade approach that should be taken on the live implementation.
The upgrade of the live system went smoothly as planned – but then something cropped up which we didn’t expect. The style sheets which we had copied from the main CMS system (in order that the new application would appear to be pretty seamless) was refusing to load properly in all browsers – Firefox, IE and Safari.
Loading the CSS file directly into the address bar of the browser, and then looking at the page info of the file, we soon found what the problem was. The stylesheet was being incorrectly identified as text/html rather than text/css.
Searching for a fix to the issue (which seems to be an IIS one) didn’t turn up anything which we could used. We tried a few things, took on board some suggestions, but nothing worked – we still had the same problem.
In the end though, the fix was quite simple. We added the following line to be the first line in the offending style sheet.
<?php header(‘Content-Type: text/css’); ?>
problem solved.
Leave a Reply
Want to join the discussion?Feel free to contribute!