Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 6th, 2002, 03:36 PM
trahma trahma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 33 trahma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to trahma
Question stopping image linking

I'm trying to stop people from linking to images on my server but I can't seem to locate why it's not working.

I followed Ken Coar's tutorial on stopping image linking but that doesn't seem to be working.

I have a .htaccess file with the following:

Code:
<Directory /home/www/active/images/>
SetEnvIfNoCase Referer "^http://golgo\.darktech\.org/" local_ref=1
<FilesMatch "\.(gif|jpg)">
  Order Allow,Deny
  Allow from env=local_ref
</FilesMatch>
</Directory>


I've also tried removing the <Directory> tags and that doesn't work. I've checked and mod_rewrite is working fine, and there's nothing in my error log.

I can also log referrers so that seems to be okay.

Anyone have any ideas what might be wrong? Any responses are appreciated.

--Justin

Reply With Quote
  #2  
Old February 6th, 2002, 04:11 PM
trahma trahma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 33 trahma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to trahma
I figured out why it was working for all.. I had to set it so .htaccess would process.

The problem is now every image is being forbidden.

Reply With Quote
  #3  
Old February 6th, 2002, 04:24 PM
trahma trahma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 33 trahma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to trahma
I just found FreeBSD's file.. and I pasted it into my httpd.conf file. Here is how I put it in.

Code:
# Enabling Rewite engine
RewriteEngine on

# Remove following 2 lines to enable rewrite log for debugging purpose only  
# You can't use rewritelog directive in .htaccess
# You don't need these 2 lines when everything is working as expected
#RewriteLog "/full/path/to/rewrite_log"
#RewriteLogLevel 9

# If no http_referer, like requesting your image directly by typing to full URL to image, continue it to the next condition
RewriteCond %{HTTP_REFERER} ^$ [OR]

# If it has http_referer but it doesn't match http://www.domain.com or http://domain.com, stop now and apply the rule
# If you have other user at http://user.domain.com, change it to !^http://([www\.]*)darktech\.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.*)darktech\.org/.*$ [NC]


No images will work at all on the server with that code in .htaccess

The site is http://golgo.darktech.org:8000.

The server runs on port 80, but is behind a linux firewall which forwards port 8000 to port 80 on the correct server via iptables if that matters.

I'd also like to have it redirect to another image, even though I know the existing code wont.

Thanks again for any help..

--Justin

Reply With Quote
  #4  
Old February 6th, 2002, 07:12 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Your question has been asked and answered many many times. If you do further search you should be able to get more examples.

Actually Ken Coar's example is not reliable and he made a stupid mistake.
<FilesMatch "\.(gif|jpg)">

This will match foobar.gif.html as well. So you need to add a $ sign to the end like so:

<FilesMatch "\.(gif|jpg)$">

>> <Directory /home/www/active/images/>

It's a good practice to always double-quote the path and remove the trailing slash inside a <Directory> directive. So it should be:

<Directory "/home/www/active/images">

So let's put it all together:
Code:
SetEnvIfNoCase Referer "^http://go1go\.darktech\.org/" my_site   
<Directory "/home/www/active/images">
  Options -Indexes FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
  Allow from my_site
<Directory> 

As you can see, no <FilesMatch> is needed. Why? Because only image files should reside in your images directory, therefore no further evaluation is ever needed.

Last edited by freebsd : February 6th, 2002 at 07:14 PM.

Reply With Quote
  #5  
Old February 7th, 2002, 11:05 AM
trahma trahma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 33 trahma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to trahma
Everything in my images directory wants to come back as forbidden now. Any ideas why? I've read all the posts I can find by searching and can't seem to figure out whats wrong. Here's my code

Code:
SetEnvIfNoCase Referer "^http://golgo\.darktech\.org/" my_site
<Directory "/home/www/active/images">
  Options -Indexes FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
  Allow from my_site
</Directory>


I've tried adding

Code:
RewriteEngine on


before which didn't seem to work either. I tried adding :8000 after the site address which didn't work as well. Any other ideas? I'm still at a loss as to what is wrong.

--Justin

Reply With Quote
  #6  
Old February 7th, 2002, 11:14 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry I forgot the env=. Change that line from Allow from my_site to Allow from env=my_site

Reply With Quote
  #7  
Old February 7th, 2002, 02:11 PM
trahma trahma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 33 trahma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to trahma
it still tells me forbidden =(

Code:
SetEnvIfNoCase Referer "^http://golgo\.darktech\.org/" my_site
<Directory "/home/www/active/images">
  Options -Indexes FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
  Allow from env=my_site  
</Directory>


See anything else wrong? Thanks for all your help thus far.

--Justin

Reply With Quote
  #8  
Old February 7th, 2002, 07:43 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
If you try to browse the images directory, of course you will get 403 on the entire page. The -Indexes was there for that purpose.

Reply With Quote
  #9  
Old February 8th, 2002, 04:15 PM
trahma trahma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 33 trahma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to trahma
it happens when i use an image in an html file on the server or goto the image directly.
(http://golgo.darktech.org:8000/test.html and http://golgo.darktech.org:8000/images/avatar3.gif respectively)

--Justin

Reply With Quote
  #10  
Old February 8th, 2002, 08:57 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> when i use an image in an html file

I see what the problem was. You need to add .* to the Referer URL like so:

SetEnvIfNoCase Referer "^http://golgo\.darktech\.org/(.*)" my_site

>> goto the image directly

You can't go to image directly because it doesn't send Referer.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > stopping image linking


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway