【问题标题】:Using php code on html page using htaccess file使用 htaccess 文件在 html 页面上使用 php 代码
【发布时间】:2021-05-26 16:06:35
【问题描述】:

我在使用 php7 的共享 linux 服务器上。我希望我的 .html 页面使用 php。我已经尝试了这里的所有答案,到目前为止都是;

AddType application/x-httpd-php7.0 .html .htm - 尝试打开页面时下载页面

AddHandler application/x-httpd-imh-php70 .html - 什么都不做

【问题讨论】:

  • 试试AddHandler application/x-httpd-php .html .htm

标签: php linux apache .htaccess server


【解决方案1】:

我在 .htaccess 中对此进行了测试,为我工作:

<FilesMatch ".+\.(htm|html)$">
    SetHandler application/x-httpd-php
</FilesMatch>

https:/www.example.com/test/my.html 或 my.htm 将被 php7 解释。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-08
    • 2016-11-23
    • 1970-01-01
    • 2014-04-17
    相关资源
    最近更新 更多