Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

    DocumentRoot /home/www/

    SuexecUserGroup host1 www

    <Directory "/home/www/">
        AllowOverride All
        Options +ExecCGI
        AddHandler fcgid-script .php
        FcgidWrapper /home/www/
        Order allow,deny
        Allow from all

The problem is, that it also runs files like (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?

share|improve this question

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
share|improve this answer
Please read carefully. This is what I have and it is still executing if there is .php in the file name followed by the dot. Dollar sign was my first guess but failed so I'm still using the line without dollar. – dev-null-dweller Nov 25 '10 at 22:54
I blame the travel time and the tryptophan. :) Updated my answer to actually answer your question. – Andrew M. Nov 25 '10 at 23:32
Does not work, besides there is no handler for HTML files. HTML was only example, it applies to all extensions: test.php.gif, test.php.txt etc. are all treated as fastcgi scripts, so even if removing handler would work, there is no way to define all possible extensions to remove handler. – dev-null-dweller Nov 26 '10 at 8:30
up vote 0 down vote accepted

Ok, I managed to solve this. Instead of AddHandler I used AddType with handler name:

AddType fcgid-script .php

And now it works only for *.php files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.