Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Nov 2000
Posts: 915
Developer
Developer
Offline
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
Developer
Developer
Offline
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
Spotlight Winner
Spotlight Winner
Offline
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
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
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
Developer
Developer
Offline
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
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
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)