Make PHP interpret other files

is it possible to use an .htaccess file to make the PHP interpreter parse other file extensions, like PNG for example…

(the file itself is obviously written in PHP, but I just need it to be interpreted like a normal .php file)

Yes. For example, to parse .html and .htm files, just include a line similar to the following in your .htaccess file.

For PHP 4…

AddHandler php-cgi .html .htm

For PHP 5…

AddHandler php5-cgi .html .htm


Save [color=#CC0000]$50[/color] on DreamHost hosting using promo code [color=#CC0000]SAVEMONEY[/color] ( Click for promo code details )

Awesome, thanks for your help! :slight_smile:

Yikes! Someone by the name of GrimReapa looking to enable executable image files. Shivers

I hope Firefox handles unrecognized file content with discretion. What’s your website? I’d like to not go there.

Just Kidding. I think…

Hey, I didn’t think of it from that angle, I guess I am now an accessory :blush:


Save [color=#CC0000]$50[/color] on DreamHost hosting using promo code [color=#CC0000]SAVEMONEY[/color] ( Click for promo code details )

Well, if it executes as PHP, it could only do what a regular PHP file can do. If it generates an image, the code is done and the saved image isn’t going to run any php. Kinda like saving the output of a PHP page as plain static HTML.

Not sure what the purpose would be though, since you can just link to a PHP file as an image, then set the content-type accordingly–like a random image script does.

Also, I’m not sure regular images would display correctly if PHP is trying to handle them like a PHP script that has been renamed to .jpg/gif/etc. I’ll have to play around with that one of these days when I’m not too busy being lazy. :wink:

:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.