Reputation: 560
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
Upvotes: 1
Views: 270
Reputation: 417
Use something like:
RewriteEngine on
RewriteRule ^(.*)\.png$ $1.php
How to change the PHP file extension using .htaccess file on GoDaddy Linux Hosting?
Upvotes: 1
Reputation: 5553
You can use PHP-GD libraries to save the file as a PNG (something like imagepng()).
Then, if wanted, you can use hearders to display or force download.
Upvotes: 0