Apache忽略扩展并通过fastcgi执行其他文件

我在configurationapache时遇到一个问题,只能通过FastCGI运行.php扩展名的文件。 示例VirtualHostconfiguration:

 <VirtualHost 192.168.0.185:80> ServerName host1.example.com DocumentRoot /home/www/host1.example.com/WWW/ SuexecUserGroup host1 www <Directory "/home/www/host1.example.com/WWW/"> AllowOverride All Options +ExecCGI AddHandler fcgid-script .php FcgidWrapper /home/www/host1.example.com/fcgi/php5.fcgi Order allow,deny Allow from all </Directory> </VirtualHost> 

问题是,它也运行像whats.new.in.php.6.html (基本上每个文件包含.php后面的点)作为fastcgi文件,而不是作为静态内容。 我试着改变AddHandler

 AddHandler fcgid-script .php$ 

没有运气 – PHP文件不解释和纯文本。

有没有办法来防止这一点?

一个想法是删除美元符号。 AddHandler选项使用扩展名,而不是正则expression式或glob。 所以正确的行将在你的原始

 # With or without the leading dot, mod_mime doesn't care AddHandler fcgid-script .php 

至于为什么它的标志性的HTML文件作为可执行文件,我不知道 – 可能有一个标志设置它,也许在默认configuration。 但是,作为解决方法,您可以通过使用以下内容来删除 .html文件的处理程序 ,以便将它们视为正常的文本/ html文件。

 RemoveHandler .html 

好吧,我设法解决这个问题。 而不是AddHandler我使用处理程序名称的AddType

 AddType fcgid-script .php 

而现在它只适用于*.php文件。