可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I have read about 10 questions like this, but there seems to be no answer to this simple question.
What could cause .htm files to be downloading instead of executed as php?
I am using the following code:
AddType application/x-httpd-php htm
I have tried many combinations but no success.
What else can I try?
All I need is .htm and .html files to execute php.
回答1:
Use AddHandler
also, change htm
to .htm
and add .html
AddHandler application/x-httpd-php .htm .html AddType application/x-httpd-php .htm .html
http://www.suffix.be/blog/addhandler-addtype-directives
回答2:
I had the same issue but then i figured the version of php i'm using is php5. I changed the handler to the following and it worked!
AddHandler x-httpd-php5-3 .php AddHandler application/x-httpd-php5 .php
回答3:
Add this line to your .htaccess file (Solved)
AddHandler application/x-httpd-php5 .php .php4 .php5 .html .htm .phtml .shtml
回答4:
Try: application/x-httpd-ea-php5 or application/x-httpd-ea-php56 for PHP 5.6 I had to change to this after upgrading to EasyApache 4
Doug Smartlab Software
回答5:
I had the same problem and couldn't find the answer here. Did find it on this cpanel forum though: https://forums.cpanel.net/threads/php-script-is-not-working-in-html-file.595195/
Their advice was to use this:
AddHandler application/x-httpd-ea-php56 .htm .html .shtml AddType application/x-httpd-php5 .php
I was using PHP together with JSON though. After this PHP did work, but JSON didn't. Solved it by removing the AddType and sticking with the AddHandler
AddHandler application/x-httpd-ea-php56 .htm .html .shtml
回答6:
Try
AddHandler fcgid-script .htm .html
Or
AddHandler x-mapp-php5 .html .htm