3

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.

bsod99
  • 1,287
  • 6
  • 16
  • 32

4 Answers4

8

Try this

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

The above setting will work if the apache is picking php as a module.

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

or

 AddHandler application/x-httpd-php5 .html .htm

above will work if apache is executing php as CGI?

there is no harm i would say to put both of the above conditions together but try one over other and see if it work for you.

read more here in this article I wrote.

cigien
  • 57,834
  • 11
  • 73
  • 112
Jaspreet Chahal
  • 2,759
  • 1
  • 15
  • 17
4

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?

Community
  • 1
  • 1
TerryE
  • 10,724
  • 5
  • 26
  • 48
  • Hi, it's running as CGI. I've tried those options you've mentioned anyway, just to rule them out. If I run phpinfo(), Server API is CGI. – bsod99 Feb 20 '12 at 23:23
  • Sorry, but for the reasons in my PS above, this conclusion may be wrong. – TerryE Feb 21 '12 at 01:59
  • I've just checked the Dreamhost wiki. It uses suEXEC \([here](http://wiki.dreamhost.com/index.php/Suexec)\), but comments in passing that it infact now uses FastCGI \([here](http://wiki.dreamhost.com/PHP_FastCGI)\). You need to set up for FastCGI. This is one to resolve on http://discussion.dreamhost.com/ – TerryE Feb 21 '12 at 02:22
  • 1
    My personal experience was that `AddType application/x-httpd-php .html .htm` prompted me to download the file and `AddHandler x-httpd-php .html .htm` did not run the PHP. `AddType application/x-httpd-php5 .php .html` used PHP 5.2.x but the original `AddHandler php5-cgi .html .htm` used the PHP I had set for my site (5.4.x). – allicarn Jun 29 '14 at 04:56
1

I've got the same problem as you but I just put this AddType php .html .htm to my .htaccess, it's working.

Kannika
  • 2,538
  • 2
  • 27
  • 38
0

For me it is working for only like this:

AddHandler php-cgi .php .htm
Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115