php - 服务器不将 .html 解析为 PHP

标签 php apache .htaccess

我的 .htaccess 文件中有包含的代码,但我尝试包含的 php 代码不起作用。

Options +Includes
AddType text/html  .htm .html
AddHandler server-parsed .htm .html
AddType application/octet-stream .vcf
AddOutputFilterByType DEFLATE text/html text/htm text/plain text/css text/php    text/javascript application/x-javascript

最佳答案

试试:

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

更新 1

它可能是特定于 PHP 版本的。如果您使用的是 PHP5,请尝试:

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

更新 2

试试:

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

或者这里还有另一种方法:

<FilesMatch "\.html$">
    ForceType application/x-httpd-php
</FilesMatch>

关于php - 服务器不将 .html 解析为 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6295141/

相关文章:

php - 格式化 PHP Echo

apache - 使用 "Redirect"和 "ProxyPass"

apache - 使用 .htaccess 将动态(可变)子域重定向到 Controller

reactjs - prerender.io .htaccess 变量 - Reactjs CRA

linux - 为什么我不能在 PHP 中使用 awk

php - undefined variable : errors -- Laravel 5. 2

php - Yii2 Restful api 对象未找到错误

c++ - 在 VSP 中为 apache 编译 passenger 时出现错误 "out of memory allocating"

php - Laravel 项目旁边的 Wordpress 项目(在 public_html 文件夹中)

wordpress - 将 wordpress 站点转换为 HTTPS