1

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?

2 Answers 2

0

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 
3
  • 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. Commented Nov 25, 2010 at 22:54
  • I blame the travel time and the tryptophan. :) Updated my answer to actually answer your question. Commented Nov 25, 2010 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. Commented Nov 26, 2010 at 8:30
0

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.