Is there a way to make apache server interpret files with .png extension as .php? Can it be done with .htaccess?
my .htaccess
RewriteEngine On
AddType application/x-httpd-php .php .png
my image.png
<?php
showImage();
function showImage()
{
$image = @imagecreatefrompng("../aimage.png");
header("Content-type: image/p开发者_JAVA百科ng;");
imagepng($image );
imagedestroy($image);
}
?>
and its not working.
When i go to www.example.com/image.png i get 'The image cannot be displayed because it contains errors', when that image.png is image.php it displays the image like it should.
Any ideas?
You say you have Apache? Add this to your .htaccess
or httpd.conf
file.
AddType application/x-httpd-php .php .foo
精彩评论