LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-19-2003, 01:50 AM   #1
brandog
LQ Newbie
 
Registered: Mar 2003
Location: Winnipeg
Distribution: RedHat 8.0
Posts: 28

Rep: Reputation: 15
Off site image blocking!


Is thier a feature or something I could do to block people from linking my images out of my domain, something like geocities or tripod does! I would like to do this for the fact that if somebody posts alot of images being accessed it will take away from my total server bandwith and resources!
 
Old 04-19-2003, 09:21 AM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,597

Rep: Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080
To prevent others from linking to your images put the following in your apache config file:

Code:
Rewriteengine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://your_domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.your_domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.trusted.com/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG)$ - [F]
This basically says if you have a referer that is not blank and not from your site or a site you allow to link images (trusted.com) then rewrite the request to - and give a forbidden response. You could replace the last line with:
Code:
RewriteRule \.(gif|jpg|GIF|JPG)$ http://www.your_domain.com/fake_image.gif [R,L]
and have fake_image.gif be an image saying not to link from your site (or anything you want really).

--jeremy
 
Old 04-19-2003, 12:06 PM   #3
brandog
LQ Newbie
 
Registered: Mar 2003
Location: Winnipeg
Distribution: RedHat 8.0
Posts: 28

Original Poster
Rep: Reputation: 15
I have edited and added that code to my httpd.conf file so lets see if it works!

ahhhh you cant post pics here!

Last edited by brandog; 04-19-2003 at 12:08 PM.
 
Old 04-19-2003, 12:12 PM   #4
brandog
LQ Newbie
 
Registered: Mar 2003
Location: Winnipeg
Distribution: RedHat 8.0
Posts: 28

Original Poster
Rep: Reputation: 15
It's not working! I restarted my http server aswell! Is there a spacific place I have to insert it!
 
Old 04-19-2003, 12:29 PM   #5
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,597

Rep: Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080
First make sure you have mod_rewrite enabled (although apache should have errored on restart if you didn't). You can put the chunk of code in the virtual host statement of the site you want to protect. How are you testing this?

--jeremy
 
Old 04-19-2003, 12:47 PM   #6
brandog
LQ Newbie
 
Registered: Mar 2003
Location: Winnipeg
Distribution: RedHat 8.0
Posts: 28

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by jeremy
First make sure you have mod_rewrite enabled (although apache should have errored on restart if you didn't). You can put the chunk of code in the virtual host statement of the site you want to protect. How are you testing this?

--jeremy
I' testing this by adding an image tag to another forum which allows pics to be posted! Mod_rewrite is enabled!

I dont have any virtual hosts set up! Just 1 main site under the /home directory!
 
Old 04-19-2003, 01:03 PM   #7
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,597

Rep: Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080
You should just be able to put the rewrite statements at the end of the file then (or almost anywhere outside of another statement). Are you getting any errors? You may want to turn rewrite logging on:

Code:
RewriteLog "/usr/local/apache/logs/rewrite.log"
RewriteLogLevel 9
This will log EVERYTHING so don't leave it that way for production, just so we can figure out what is happeneing. You can adjust the path to suit your setup.

--jeremy
 
Old 10-07-2003, 11:03 AM   #8
Brando_ou812
LQ Newbie
 
Registered: Sep 2003
Posts: 2

Rep: Reputation: 0
Finally got this to work a bit but the image shows up as a red X and you right click and it still shows the original linking to the pic! The RewriteRule doesent seem to change the link to the image??
 
Old 10-07-2003, 11:58 AM   #9
Brando_ou812
LQ Newbie
 
Registered: Sep 2003
Posts: 2

Rep: Reputation: 0
figured it out the RewriteRule \.(gif|jpg|GIF|JPG)$ http://www.your_domain.com/fake_image.gif [R,L]

Has to have these brackets {} not these ()

http://www.manitobamotorsports.com/m...005%20copy.jpg

Last edited by Brando_ou812; 10-07-2003 at 12:00 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Do you know sourceforge site? How to upload to this site? TruongAn General 2 07-02-2005 05:26 AM
KDE Konqueror, can't read local image of a site tongar SUSE / openSUSE 1 04-28-2005 01:50 PM
can not upload image to site via php script vinsky2002 Linux - Software 0 03-15-2005 12:27 AM
blocking a site with /etc/hosts corso64 Linux - Networking 6 12-03-2004 04:29 AM
Site Blocking mathew5 Slackware 7 09-16-2004 12:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration