CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Stopping offsite linking to images



May 19, 2001, 8:44 PM

Post #1 of 3 (2545 views)
Stopping offsite linking to images Can't Post

Hi. I run a small free web hosting service, and am having problems with people storing their images on my server, and then linking to them from other websites (thus using my bandwidth and costing me money!). Is there any way that I can stop people from doing this?

I know that I could write a script in Perl, but the only way that I can think of doing this is having all the images behind a script ie. instead of the location of each image being shown as then it would be something like However, this isn't very practical for my purposes.

I've noticed that with the larger free web hosting providers such as GeoCities, if you try to link to images stored on their server from offsite, you will be shown an "error" image in their place. Does anyone know how they do this? Is it something that can be done on the server level? (I'm running my site off a dedicated Unix server; is there anything I can set on the server to stop people linking to the images on there?)

Any suggestions or help would be very much appreciated!


May 21, 2001, 4:47 AM

Post #2 of 3 (2534 views)
Re: Stopping offsite linking to images [In reply to] Can't Post

You cannot solve this with a script, but you have to configure this in your .httpd config, by routing all requests for imagefiles to a .sh script.
Such as :
if (extension=gif/jpg) {check referer}
if (referer ne your.domainname) {show error image}


May 21, 2001, 8:26 AM

Post #3 of 3 (2527 views)
Re: Stopping offsite linking to images [In reply to] Can't Post

Try this needed mod_rewrite,
I use it for linking images.
You can try to link my images

Protecting your images from linking

For this you need mod_rewrite have installed on your webserver.
Put a file named .htaccess in the directory where you have the images located.

AuthUserFile /dev/null
AuthGroupFile /dev/null

RewriteEngine On

RewriteCond %{HTTP_REFERER} !^* [NC]
RewriteCond %{HTTP_REFERER} !^* [NC]
RewriteCond %{HTTP_REFERER} !^* [NC]
RewriteCond %{HTTP_REFERER} !^* [NC]
RewriteCond %{HTTP_REFERER} !^* [NC]

RewriteRule /* [R,L]

By the RewriteCond change the web address name for who are allowed to use your images.
By the RewriteRule change the web address name where to send the ones who are linking to.

You need to write for every web address a new line.
Remember: is not the same like


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives