PHP FastCGI process images named file.php.gif

Hi there,

I have an interesting issue. I installed a PHP application that has image file with strange formats, such as:


The problem is that instead of simply loading this as an image, apache is processing this as PHP.

I used FastCGI handler for PHP, so I imagine there is something in the handler settings in Apache that is causing this. But I am curious to know if anyone has a fix for this so that PHP only load files that ‘end’ in .php, but does not process files that might have .php. somewhere in the filename.


OK, I think I solved it. In the httpd.conf, for each virtualhost, you have to change:

AddHandler fcgid-script .php
AddHandler fcgid-script .php5


AddType fcgid-script .php
AddType fcgid-script .php5

This will solve the problem. Now, is there any way to make this a permanent change so that future virtual hosts get created with this fix?


If you rename the files to something without the “.php.” in it, and then browse to that file in your browser, does it seem to work correctly at that point?

In theory, what you’re seeing shouldn’t happen though :slight_smile:

There’s a line in Apache like this one which defines what a .php file is:

AddType application/x-httpd-php5 .php

And then a line like this which says what to do with a .php file:

Action application/x-httpd-php5 /cgi-bin/php5.cgi

So, php5.cgi should only be run if the file ends in .php.

If you’re seeing that gif file being executed – that suggests Apache is somehow associating that file as a .php file, not a .gif file.

I lean towards thinking something else is at work :slight_smile:

Is there by chance a .htaccess file in that directory that’s causing some confusion?