People linking images from my site

Soldato
Joined
18 Oct 2002
Posts
5,408
Is there any way to stop people doing this? Like instead of displaying the image it will display a different image? Something saying like "stolen from mattsbabes.co.uk" or something?

And if this can be done if there a way to let certain images be hotlinked? So I can still post images on forums and stuff?

^ Hope that makes sense. :)
 
Soldato
Joined
18 Oct 2002
Posts
5,464
Location
London Town
You need to create a file in notepad called '.htaccess' . It must be named just that; no .txt after or anything.

In this file put the following:
--------------------

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www.yoursite.com [NC]
RewriteCond %{HTTP_REFERER} !^http://www.aforum.com [NC]

RewriteRule [^/]+.(gif|jpg)$ http://www.mattsbabes.co.uk/leecherspicture.jpg [R,L]

--------------------
Basically the line:

RewriteCond %{HTTP_REFERER} !^website address [NC]

must be repeated for every site you want to allow the images to be shown on, including site subdomains and so on.

For the final line just replace the URL with your image of choice (this is the replacement 'stolen from...' image)

Save the .htaccess file and upload to the directory of choice (it must be in each directory, placing it in the root won't cover all the subdirectories).

As a further note, if it's for bandwidth issues, make a 1x1 pixel gif as your replacement image. With a big 'stolen from...' image you're negating the point of doing it since you'll still use the same bandwidth.

Hope that makes sense.
 
Soldato
OP
Joined
18 Oct 2002
Posts
5,408
Thanks Augmented. That was just what I needed. :)

That will stop people stealing the pics of yummy Reiko. She's all mine. ;)

Edit: Just set it up and went to the site with my stolen picture and it seems to be downloading 100s of KBs. :confused:
 
Last edited:
Associate
Joined
9 Nov 2002
Posts
745
Location
Bucks [uk]
Originally posted by Augmented
No problem, bear in mind it will only work on Apache servers.
There is a cleaner way of doing it, but you need access to the server itself.

Just outta intrest, What would be the cleaner way of doing this? As i'm quite intrested

Thanks
 
Soldato
Joined
18 Oct 2002
Posts
5,464
Location
London Town
Originally posted by Bloo_Fish
Just outta intrest, What would be the cleaner way of doing this? As i'm quite intrested

Thanks
Didn't really take note of it when I saw the process, since I don't have access to one. It's done in the server httpd.conf (config) file. Basically the same, but more efficient since the server doesn't have to check the .htaccess each time.
Do a google search about it, as I'm not sure how exactly you implement it myself.

(cut-and-pasted from another forum)

<Directory "/path/to/your/images">
Options +FollowSymLinks
### Protect Local Images
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [NC,F]
</Directory>

You can also prevent leeching of any other formats (also with the htaccess method), just add them in the rewrite rule (jpeg|mid|exe|zip|mp3) and so on.

------------------
Originally posted by Matthew-1985
Edit: Just set it up and went to the site with my stolen picture and it seems to be downloading 100s of KBs. :confused:
Try placing your replacement image in a different directory to the ones you are preventing leeching.
 
Last edited:
Soldato
OP
Joined
18 Oct 2002
Posts
5,408
Originally posted by Augmented
Try placing your replacement image in a different directory to the ones you are preventing leeching.

It is. What would happen if you put the .htaccess in the folder with the leechers picture? I think I might have. :confused:
 
Soldato
Joined
18 Oct 2002
Posts
5,464
Location
London Town
Originally posted by Matthew-1985
It is. What would happen if you put the .htaccess in the folder with the leechers picture? I think I might have. :confused:
It shouldn't matter.
But there's something about an infinite loop occuring I believe, if the htaccess is written incorrectly.
If the htaccess for a directory changes an image to leecher.jpg on a blocked site; then it finds that the leecher.jpg under its control is now consequently being leeched by the blocked site. This loops infinitely unless the correct condition exists in the file.
That's what I picked up anyway. Not sure if that's right at all, beyond the scope of my knowledge on this.
 
Soldato
OP
Joined
18 Oct 2002
Posts
5,408
It seems to be stopping some of my sigs working now. :(

How do you remove the .htaccess file? It don't show up in Cute FTP or IE. :confused:

Edit: Never mind I found a guide on how to show all files in Cute FTP and my sigs seem to be working again. :)
 
Last edited:
Soldato
Joined
18 Oct 2002
Posts
5,464
Location
London Town
Originally posted by Matthew-1985
How do you remove the .htaccess file? It don't show up in Cute FTP or IE. :confused:
It's hidden by default, I'm not sure you can stop IE hiding it. You need to enable 'show all files' (-a switch) in the client. Enabling it in CuteFTP is done this way it appears.

/just seen your edit, but I'll leave that there.
 
Back
Top Bottom