再次启用 apache2 以使用 .htaccess 将 html 文件解析为 php7
enable again apache2 to parse html file as php7 using .htaccess
我有一个 Ubuntu 16.04 64 位桌面和 php7 默认启用。
我的一些客户喜欢将 php 脚本嵌入到 html 页面中。
前段时间我写了一个这样的 .htaccess 文件:
RemoveHandler .html .htm
AddHandler application/x-httpd-php .php .html .htm
现在这个语法不再有效了。
我尝试了很多相同的语法但没有任何效果。
我不得不更改 /etc/apache2/mods-enabled/php7.0.conf 添加
<FilesMatch ".+\.html?$">
SetHandler application/x-httpd-php
</FilesMatch>
但这不是一个好的解决方案:所有 html 页面都可以解析为 php 文件!
谁有正确的新配置?
P.S。在站点的 conf 文件中,我在站点目录
上启用了 AllowOverride All
您可以在 .htaccess
中尝试以下解决方案:
AddType application/x-httpd-php .html .htm
为我工作 PHP7。
我有一个 Ubuntu 16.04 64 位桌面和 php7 默认启用。
我的一些客户喜欢将 php 脚本嵌入到 html 页面中。
前段时间我写了一个这样的 .htaccess 文件:
RemoveHandler .html .htm
AddHandler application/x-httpd-php .php .html .htm
现在这个语法不再有效了。
我尝试了很多相同的语法但没有任何效果。
我不得不更改 /etc/apache2/mods-enabled/php7.0.conf 添加
<FilesMatch ".+\.html?$">
SetHandler application/x-httpd-php
</FilesMatch>
但这不是一个好的解决方案:所有 html 页面都可以解析为 php 文件!
谁有正确的新配置?
P.S。在站点的 conf 文件中,我在站点目录
上启用了AllowOverride All
您可以在 .htaccess
中尝试以下解决方案:
AddType application/x-httpd-php .html .htm
为我工作 PHP7。