1

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

Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127
P. Danielski
  • 550
  • 7
  • 17

2 Answers2

1

Use something like:

RewriteEngine on

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

How to change the PHP file extension using .htaccess file on GoDaddy Linux Hosting?

Community
  • 1
  • 1
0

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.

Artur Grigio
  • 5,185
  • 8
  • 45
  • 65