有没有办法使apache服务器将扩展名为.png的文件解释为.php?

问题描述

| 有没有办法使apache服务器将扩展名为.png的文件解释为.PHP?可以使用.htaccess完成吗? 我的.htaccess
RewriteEngine On
AddType application/x-httpd-PHP .PHP .png
我的image.png
<?PHP

showImage();

function showImage()
{
    $image = @imagecreatefrompng(\"../aimage.png\");
    header(\"Content-type: image/png;\"); 
    imagepng($image );
    imagedestroy($image);
}

?>
它不起作用。 当我去www.example.com/image.png 我得到“图像无法显示,因为其中包含错误\”, 当该image.png是image.PHP时,它将显示应有的图像。 有任何想法吗?

解决方法

您说您有Apache?将此添加到您的
.htaccess
httpd.conf
文件中。
AddType application/x-httpd-php .php .foo