Forum Moderators: phranque

Message Too Old, No Replies

.htaccess deny page

Can I deny people from viewing my automatic image generator?

         

rob7591

8:43 pm on Nov 19, 2009 (gmt 0)

10+ Year Member



Hi,

I have a dynamic image generator that I use for thumbnails like this:

<img src="image.php?src=myimage.jpg&width=150&height=200" />

Is there a way I could deny people from navigating to www.example.com/image.php ?

Also, is there a way I could deny other websites from using this image generator on their websites externally?

Because most of my thumbnails are the same size, I was thinkin I would do a rewrite like:
www.example.com/small-images/myimage.jpg
www.example.com/medium-images/myimage.jpg
etc.

, but I'd rather have it just deny everything unless it's coming from my HTML on my domain if possible.

jdMorgan

2:01 am on Nov 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When "your" HTML page(s) loads, set a cookie. Check for the cookie in your image.php script. If the cookie isn't set, return a 403-Forbidden response or a small-filesize replacement image with your Web site's URL plastered across it. If the cookie is set, serve the requested image. Make this a session cookie, so it self-deletes when the browser is closed.

BTW, don't present anything "rude" if the cookie isn't set; Consider that some visitors to your site may run with cookies disabled... So be nice. :) You might even want to set a 'test cookie' on the home page if visitors go there before getting to your galleries, and if a gallery page is loaded without that cookie, then warn that your site requires a session cookie (though don't say why, for your site's own security). I'm totally guessing how your site may be set up, but you probably get the idea...

Jim