简体   繁体   中英

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.

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

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?

我遇到了和你一样的问题,但我把这个AddType php .html .htm放到了我的.htaccess,它正在运行。

对我来说,它只是这样工作:

AddHandler php-cgi .php .htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM