用于解析 html 文件中的 php 的 htaccess 规则不起作用 [英] htaccess rule to parse php in html files not working

查看:40
本文介绍了用于解析 html 文件中的 php 的 htaccess 规则不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一生都无法弄清楚为什么这不起作用 - 在 Dreamhost 服务器上,我创建了一个 htaccess 文件并将 AddHandler php5-cgi .html .htm 添加到根据 Dreamhost 文档,允许在 html 文件中使用 php.在一个相同的 Dreamhost 包上,我为另一个站点做了同样的事情,它运行得很好,但在这种情况下,它只是不会解析 php!有什么我可能在这里错过的可能导致问题的吗?htaccess 位于 Web 根目录中,不会被其他任何内容覆盖.

can't for the life of me work out why this isn't working - on a dreamhost server, I've created an htaccess file and added AddHandler php5-cgi .html .htm to allow php in html files, as per the dreamhost docs. On an identical dreamhost package, I've done the same thing for another site and it worked perfectly, but in this case it just won't parse the php! Is there anything I could have missed here which could be causing the problem? The htaccess is in the web root and isn't being overridden by anything else.

推荐答案

您的服务器是否使用 suPHP 而不是 mod_php 或普通的 php-cgi?

Is your server using suPHP rather than mod_php or plain php-cgi?

尝试使用

AddHandler x-httpd-php .html .htm

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

相反.

共享主机服务使用基于 UID 的个人帐户相互分离.大多数使用suPHP,但有些使用suEXEC.他们将使用其中之一.两者都充当 php-cgi 的 su 包装器,因此您无法从 phpinfo() 作为其 PHP 脚本引擎中分辨出来,因为这将报告 Server API CGI/FastCGI 在这两种情况下.对于 CGI 启动的脚本,phpinfo 不会报告 Apache 配置.您需要查看托管服务提供商的常见问题解答或可能尝试:

Shared Hosting services use UID based separation on individual accounts from each others. Most use suPHP, but some use suEXEC. They will use one of these. Both act as a su wrapper around php-cgi so you can't tell from the phpinfo()as its PHP scripting engine as this will report Server API CGI/FastCGI in both cases. For CGI initiated scripts, phpinfo doesn't report on the Apache config. You need either to look at your hosting provider's FAQ or possibly try:

 <?php
 header( "Content-Type: text/plain");
 echo system('grep -iR LoadModule /etc/httpd /etc/apache2');

托管服务提供商的支持论坛/常见问题解答可能会在此处提供具体的配置建议.你试过吗?

The hosting provider's support forums / FAQ might give specific configuration advice here. Have you tried them?

这篇关于用于解析 html 文件中的 php 的 htaccess 规则不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆