Apache returning text/html on some png files
Did you make sure png files are valid image files? If you are on a Linux platform you can try the file command
file somefile.png
That command should return something along the lines of
PNG image data, 318 x 15, 8-bit/color RGB, non-interlaced
You can also try to view the file with a image viewer.
The problem for me was that the image file to be delivered was named pear.php.net-sos8j3lis2j.png
.
Apache's AddHandler
directive - that's used to assign the PHP interpreter to .php files
- supports multiple extensions, and pear.php.net.png
was seen as having three extensions: .php
, .net
and .png
. .php
was the first, to the php interpreter was invoked.
text/html
was then sent out by either apache or PHP, I don't know.
What I had to do to fix the problem:
Replace all instances of
AddHandler php-cgi .php
with
<FilesMatch \.php$>
SetHandler php-cgi
</FilesMatch>