Point An Tag To A Image Dynamically Generated By PHP?

- 1 answer

Is it possible to redirect an image to a dynamically generated image(using PHP)?

I have a dynamically created image and it has an extension ".PHP" (obviously) and that server is not under my control. So I want to redirect "somename.jpg" (on my server) to "remoteserver/dynamicimage.php" (on some remote server not under my control) so that I can right away link it as <img src="somename.jpg"/> and the dynamically generated image is shown.

Please let me know if this is possible.



Browsers follows redirects for images. Create a php-file called "somename.jpg" and add:


Use the Apache directive ForceType in an .htaccess file to tell the server to process the .jpg file as php:

<Files somename.jpg>
    ForceType application/x-httpd-php

Or just call the file somename.php if you don't really need the .jpg extension.

You could probably accomplish this using mod_alias as well, although I haven't tried it:

Redirect somename.jpg

This would go in an .htaccess file as well.