将.html文件parsing为PHP的常用方式是将以下行的第一个(PHP作为Apache模块)或两者(PHP作为CGI)添加到.htaccess文件中:
AddType application/x-httpd-php .html .htm AddHandler application/x-httpd-php .html .htm
有时需要x-http-php5 ,具体取决于主机:
AddType application/x-httpd-php5 .html .htm AddHandler application/x-httpd-php5 .html .htm
但是,我现在正在一个新的东道主,没有渗透这些线路的工作。 在所有情况下,原始文件被发送到浏览器,并且wget显示x-httpd-php被呈现为Content-Type!
HTTP request sent, awaiting response... HTTP/1.1 200 OK Date: Tue, 07 Aug 2012 14:16:40 GMT Server: Apache Last-Modified: Tue, 07 Aug 2012 07:46:44 GMT ETag: "862239-14-4c6a83216c100" Accept-Ranges: bytes Content-Length: 20 X-Powered-By: PleskLin Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Content-Type: application/x-httpd-php Length: 20 [application/x-httpd-php] Remote file exists.
请注意, Length: 20正好是<?php phpinfo(); ?>的长度<?php phpinfo(); ?> <?php phpinfo(); ?> ,这就是它所服务的。 我已经确认,PHP是作为一个模块运行在这个SO回答中了不起的提示。 我已经和服务器的维护者(一个员工,所以即使我切换主机,我仍然想帮他解决这个问题),他不知道什么问题或正确的configuration。 服务器在基于Debian的发行版上运行Plesk,如果这很重要的话。
这实际上是一个Apacheconfiguration问题,这个页面有解决scheme: http : //kb.parallels.com/en/124
转载在这里为后人:
.htaccess文件可以通过在“/etc/httpd/conf.d/zz010_psa_httpd.conf”文件中放置以下内容来启用:
AccessFileName .htaccess <Directory "/var/www/vhosts"> Options +All AllowOverride All Order allow,deny Allow from all </Directory>然后重启Apache:
#service httpd stop #service httpd start