【发布时间】:2015-09-22 12:35:36
【问题描述】:
我有一个 html 网站,我希望将 html 页面解析为 php;我为此使用了一个 htaccess 文件。
在在线服务器上,它可以正常工作。命令是:
AddHandler application/x-httpd-php5 .html .htm
但是,在 localhost 服务器上它根本不起作用。当我访问该页面时,它会提示下载文件而不是显示该页面。
我猜我正在使用 PHP 5.6.3 和 PHP 作为模块。
我在 htaccess 中尝试过各种类似的命令,比如:
AddType application/x-httpd-php .html .htmAddType application/x-httpd-php5 .html .htmAddHandler application/x-httpd-php .html .htmAddHandler application/x-httpd-php5 .html .htmAddHandler application/x-httpd-php .html .htmAddHandler application/x-httpd-php5 .html .htmAddHandler x-mapp-php .html .htmAddHandler x-mapp-php5 .html .htm
但没有运气。
我也尝试了RemoveHandler .html .htm,但没有成功。
我检查了 httpd.conf 文件,其中有以下内容:
LoadModule php5_module "C:/Program Files/PHP/php5apache2_4.dll"
AllowOverride All
<Directory "D:/mysites/">
AllowOverride All
Require all granted
</Directory>
那我应该去哪里找问题呢..?
任何提示表示赞赏。
【问题讨论】:
-
如果你下载文件,下载的文件是否经过PHP处理?正在发送什么
Content-Type标头? (我的赌注是您列表中的第一个AddType。)