Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Nov 2000
Posts: 915
D
Developer
OP Offline
Developer
D
Joined: Nov 2000
Posts: 915
I remember seeing this a while ago here in the admin forum, but since I can't view that now, thought I'd ask. I know some people who have sites on our site network and people are linking to their images (car blueprints) and stealing bandwidth. I know it involves the rewrite engine. I'd like to possible block all .gif and .jpg files from being linked and then replacing the images with a 'You are linking to a file on our servers and stealing our bandwidth. Please cease and desist." image.

Cheers,
Dan

Sponsored Links
Joined: Nov 2000
Posts: 915
D
Developer
OP Offline
Developer
D
Joined: Nov 2000
Posts: 915
Nevermind, did some searches on google and put this together and it works fairly well:

Code
RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.my-site.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://my-site.com/.*$ [NC]
RewriteRule .*.(jpg|gif)$ illegaly-linked-image [L]

Joined: Jun 2001
Posts: 2,849
R
Spotlight Winner
Offline
Spotlight Winner
R
Joined: Jun 2001
Posts: 2,849
What is the actual syntax for the link to the image in this line?

Quote
code:
Code
RewriteRule .*.(jpg|gif)$  illegaly-linked-image        [L]

In other words, do I need to use this.

code:
[qb]
Code
  RewriteRule .*.(jpg|gif)$  !^http://www.netwerkin.com/images/dont_steal.jpg$     [L]
[/qb]
Or without the tags around the URL like this?

Quote
quote:
RewriteRule .*.(jpg|gif)$ http://www.netwerkin.com/images/dont_steal.jpg [L]

Joined: Jan 2000
Posts: 5,073
Admin Emeritus
Offline
Admin Emeritus
Joined: Jan 2000
Posts: 5,073
As an example, here's the one I use:
Code
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?solareclipse.net/ [NC]
RewriteRule .(gif|jpg)$ http://solareclipse.net/stolen.gif [R,L]
Yes, this does work - the .htaccess is in a subdirectory, so stolen.gif itself isn't filtered. If you want to protect your entire site, you should be able to get away with creating a subdirectory, then .htaccessing it with RewriteEngine off.


UBB.classic: Love it or hate it, it was mine.
Joined: Feb 2001
Posts: 817
Moderator / Kingpin
Offline
Moderator / Kingpin
Joined: Feb 2001
Posts: 817
Is there a way to use this but exempt some specific files located in the directory your protecting and also allow some specific websites?

Sponsored Links
Joined: Nov 2000
Posts: 915
D
Developer
OP Offline
Developer
D
Joined: Nov 2000
Posts: 915
Quote
quote:
Originally posted by usr bin geek:
Is there a way to use this but exempt some specific files located in the directory your protecting and also allow some specific websites?
I'm not sure about exempting some files, but if you want to allow certain specific other sites, just add some more conditions:

code:
[qb]
Code
RewriteCond %{HTTP_REFERER} !^http://(www.)?site1.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?site2.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?site3.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?site4.com/ [NC]
[/qb]
etc... wink

Joined: Jan 2000
Posts: 5,073
Admin Emeritus
Offline
Admin Emeritus
Joined: Jan 2000
Posts: 5,073
I *THINK* that you can do this, but I'm not sure:


RewriteEngine off


UBB.classic: Love it or hate it, it was mine.

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
badfrog
badfrog
somewhere on the coast of Maine
Posts: 94
Joined: March 2007
Forum Statistics
Forums63
Topics37,555
Posts293,845
Members13,842
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online 190
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 6
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,813
Greg Hard 4,625
Top Posters(30 Days)
Morgan 3
isaac 2
Top Likes Received
isaac 69
Gizmo 13
Brett 7
Morgan 2
Top Likes Received (30 Days)
isaac 3
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2021 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Snapshot build 20201211)
Responsive Width:

PHP: 5.4.45 Page Time: 0.050s Queries: 28 (0.017s) Memory: 3.3059 MB (Peak: 3.5110 MB) Data Comp: Zlib Server Time: 2021-05-06 13:36:22 UTC
Valid HTML 5 and Valid CSS