Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I set up my Apache 2 server to parse CSS files in a specific virtual host with PHP:

AddType application/x-httpd-php .css

However, the text is served with the wrong headers, meaning that the CSS files aren't used, at least in Firefox. Setting Content-Type: text/css with PHP fixes the problem, but I don't want to do that for every CSS file. How to fix this?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

I think the best way to do this is to add this to the virtual host:

AddHandler application/x-httpd-php .css

In case this results in a wrong mime-type add this too:

<Files *.css>
  Header set Content-type "text/css"
</Files>

In case you want this to only apply to css files in a specific directory you can add it to a .htaccess file in that directory instead of the virtual host or add a Directory-directive for that directory to the virtual host i.e.

<Directory /foo>
  AddHandler application/x-httpd-php .css
  <Files *.css>
    Header set Content-type "text/css"
  </Files>
</Directory>
share|improve this answer
    
This worked great. Thank you! –  Anders Jan 11 '12 at 7:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.