Apache ignoring extension and executing other files through fastcgi

apache-2.2fastcgimod-fcgid

I've got a problem with configuring apache to run only files with .php extension through FastCGI.
Sample VirtualHost configuration :

<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>

The problem is, that it also runs files like whats.new.in.php.6.html (basically every file containing .php followed by the dot) as fastcgi instead serving it as static content. I've tried changing AddHandler to

AddHandler fcgid-script .php$

With no luck – php files were not interpreted and served as plain text.

Is there a way to prevent this?

Best Answer

One idea would be to remove the dollar sign. The AddHandler option takes the extension, not a regular expression or glob. So the correct line would be in your original

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

As to why its flagging html files as executable, I have no idea--there could be a flag somewhere setting it, perhaps in a default configuration. However, as a workaround, you can REMOVE the handler for .html files by using the following, so that they will be treated as normal text/html files.

RemoveHandler .html