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
  • 9,771
  • 18
  • 75
  • 123
P. Danielski
  • 515
  • 6
  • 16

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
  • 4,639
  • 7
  • 40
  • 61