php.htaccessdreamhost

htaccess rule to parse php in html files not working


can't for the life of me work out why this isn't working - on a dreamhost server, I've created an htaccess file and added AddHandler php5-cgi .html .htm to allow php in html files, as per the dreamhost docs. On an identical dreamhost package, I've done the same thing for another site and it worked perfectly, but in this case it just won't parse the php! Is there anything I could have missed here which could be causing the problem? The htaccess is in the web root and isn't being overridden by anything else.


Solution

  • Is your server using suPHP rather than mod_php or plain php-cgi?

    Try using

    AddHandler x-httpd-php .html .htm
    

    or

    AddType application/x-httpd-php .html .htm
    

    instead.

    Postscript

    Shared Hosting services use UID based separation on individual accounts from each others. Most use suPHP, but some use suEXEC. They will use one of these. Both act as a su wrapper around php-cgi so you can't tell from the phpinfo()as its PHP scripting engine as this will report Server API CGI/FastCGI in both cases. For CGI initiated scripts, phpinfo doesn't report on the Apache config. You need either to look at your hosting provider's FAQ or possibly try:

     <?php
     header( "Content-Type: text/plain");
     echo system('grep -iR LoadModule /etc/httpd /etc/apache2');
    

    The hosting provider's support forums / FAQ might give specific configuration advice here. Have you tried them?