Re: Fooling the client into thinking php script is .jpg
| From: | Christopher William Wesley | Date: | Mon, 11 Feb 2002 05:35:36 +0000 |
| Subject: | Re: Fooling the client into thinking php script is .jpg | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84231@lists.php.net to get a copy of this message | ||
On Mon, 11 Feb 2002, Matt Moreton wrote:
> I have a script that outputs an image. Using the gd library. But the
...
> the image. Is it possible somehow to request the file as a .jpg?
> www.host.com/displayimage.php
Assuming you're using Apache, you can use a rewrite rule (with
mod_rewrite). http://httpd.apache.org/docs/mod/mod_rewrite.html
Turn the rewrite engine on, then specify a rewrite rule which tells apache
to execute your script when a certain file is requested.
Using the file names you specified, add this to your httpd.conf (or your
.htaccess):
RewriteEngine on
RewriteRule ^/displayimage.jpg$ /displayimage.php [L]
You can then just use /displayimage.jpg as an image src, then when a
visitor's browser requests it, apache will execute & return
/displayimage.php instead, and the visitor will never know.
~Chris /"\
\ / September 11, 2001
X We Are All New Yorkers
/ \ rm -rf /bin/laden