AddType in htaccess causes page to download

匿名 (未验证) 提交于 2019-12-03 01:08:02

问题:

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  


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!