开发者

Is there a way to make apache server interpret files with .png extension as .php?

开发者 https://www.devze.com 2023-02-27 02:39 出处:网络
Is there a way to make apache server interpret files with .png extension as .php? Can it be done with .htaccess?

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
0

精彩评论

暂无评论...
验证码 换一张
取 消