htaccess的规则来解析PHP在HTML文件中不工作中不、规则、文件、工作

2023-09-02 09:36:58 作者:人酷又会撩つ

不能为我的生活工作这是为什么不工作 - 一个Dreamhost的服务器上,我已经创建了一个htaccess文件,并添加 AddHandler的PHP5-CGI的.html的.htm 来允许PHP在HTML文件中,按Dreamhost的文档。在相同的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的一个苏包装,所以你不能从phpinfo()函数为PHP脚本引擎,因为这将报告 服务器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 APICGI/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?