Question: I have a php file which makes and outputs PNG images generated dynamically and I want that file to be accessible with the PNG extension rather than the PHP extension.

For example, I have www.mysite.com/image.php which outputs a PNG image, but I want something like this: www.mysite.com/image.png

I think I have to use htaccess, but I have no idea.

Thanks

Answer: 
Use something like:

```
RewriteEngine on

RewriteRule ^(.*)\.png$ $1.php

```

[How to change the PHP file extension using .htaccess file on GoDaddy Linux Hosting?](https://stackoverflow.com/questions/7897353/how-to-change-the-php-file-extension-using-htacess-file-on-godaddy-linux-hostin)
You can use PHP-[GD libraries](http://php.net/manual/en/book.image.php) to save the file as a PNG (something like [imagepng()](http://php.net/manual/en/function.imagepng.php)).

Then, if wanted, you can use hearders to display or force download.