|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
Sorry I forgot the env=. Change that line from Allow from my_site to Allow from env=my_site
|
|
#7
|
|||
|
|||
|
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 |
|
#8
|
|||
|
|||
|
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.
|
|
#9
|
|||
|
|||
|
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 |
|
#10
|
|||
|
|||
|
>> 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. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > stopping image linking |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|