title: Have Apache/PHP set MIME type based upon file extension for files being executed as PHP
body: <p>I have an Apache/PHP based server on which I've made Apache execute <code>js</code>, <code>html</code> and <code>css</code> files as PHP via the following line in <code>/etc/mime.types</code>:</p>
  
  <blockquote>
    <p>application/x-httpd-php                         phtml pht php js html css</p>
  </blockquote>
  
  <p>We did this because even though any files we save as <code>.html</code>/<code>.js</code>/<code>.css</code> are almost entirely non-PHP, we need to do a bit of templating in them (for example, changing the domain of some URLs depending upon whether we are on the live or testing server).</p>
  
  <p>The trouble is, this method of making Apache treat those files as PHP causes them to be returned with the wrong MIME type, which at the very least breaks <code>css</code> files in Chromium and probably has nasty effects in other browsers too.</p>
  
  <p>Is there a way I can tell Apache to execute these files as PHP but still output them with the correct MIME type for their file extension? I don't want to have to manually paste</p>
  
  <pre><code>&lt;?php
    header("Content-type: text/css");
  ?&gt;
  </code></pre>
  
  <p>at the top of all of our <code>.css</code> files.</p>