【问题标题】:enable again apache2 to parse html file as php7 using .htaccess再次启用 apache2 以使用 .htaccess 将 html 文件解析为 php7
【发布时间】:2017-11-29 13:20:22
【问题描述】:

我有一个 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文件!

有人有正确的新配置吗?

附:在站点的 conf 文件中,我在站点目录中启用了 AllowOverride All

【问题讨论】:

    标签: php .htaccess apache2


    【解决方案1】:

    您可以在.htaccess 中尝试以下解决方案:

    AddType application/x-httpd-php .html .htm
    

    使用 PHP7 为我工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-06
      • 2017-11-14
      • 1970-01-01
      • 2011-09-08
      • 2013-02-03
      • 1970-01-01
      • 2018-08-29
      相关资源
      最近更新 更多