Rewrite rule for image blocking


#1

Well, I thought I had it figured out, but apparently my rule is still not quite right.
What I want to do is block some but not all images, by placing the htaccess file into certain folders.
Problem I am having is my links are not working, the rewrite rule blocks my links and page refreshes.
Using the url address I can access the images, just through the above mentioned.
So I thin I need to add an additional condition to make the links work.
BTW, using the links from my menu do work.
My pages are php, and from what I can gather img src are working, but a href is not. Does this have anything to do with using relative addresses?
Here is my code
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?silkrooster.com/.*$ [NC]
RewriteRule .(gif|jpg)$ [F]
RewriteRule .(gif|jpg)$ /webgraphics/stolen.gif [R,L]

Any help is appreciated
Silk


#2

RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?silkrooster.com/.*$ [NC] RewriteRule \.(gif|jpg)$ [F] RewriteRule \.(gif|jpg)$ /webgraphics/stolen.gif [R,L]That is actually 2 parts.

  1. If the referrer is not blank or is not your own web page, and the URL is to that of a GIF or JPEG, then immediately tell the visitor access is forbidden.

  2. If the URL is to that of a GIF or JPEG, redirect the request to the specified GIF.

So whatever matches #1 stops processing and whatever doesn’t match #1 moves on to #2. Oops.

Also keep in mind a browser may have images cached. Thus it is possible to do the following:

  1. Visit a page where the images in the page are blocked.
  2. Then visit the images directly, when they are not blocked.
  3. Return to the first page, and the browser may now show the images in the page.

:cool: Perl / MySQL / HTML+CSS


#3

OK, I think I got. I guess you can only use one rule or the other. I removed the change image and it seams to be working.
It looks like I would need to go through, the conditions again for the other rule.
Oh well, this will work for now, plus it is a little more politer than having a image saying stolen on it. Even though, it is kind of funny.
Silk