I have a dynamic image, which I wish to serve looking like a static image.
e.g. Current url of the image is
http://site.co.uk/media/dynamicImage.php
I wish for the image to be accessed using
http://site.co.uk/media/dynamicImage.gif
How do I use .htaccess to serve the dynamicImage.php file when dynamicImage.gif is accessed?
Please note that I don't want to rewrite ALL files in a folder as per this example: Apache - rewrite images to php file with .htaccess, I just want to rewrite the files I specify.
Try adding these rules to the htaccess file in your document root:
You can create as many of those
RewriteRules
as you need, for each specific image. This makes it so when someone requestshttp://site.co.uk/media/image.gif
, they are actually being served the contents at/media/image.php
.If you need to keep this all within the
media
directory, e.g. you already have some rules in the media directory's htaccess file, you can modify the rules to look like: