CLBridges
11-08-2003, 07:56 AM
I checked the .htaccess help/tutorial links Sualdam had recommended in a previous post and although it's great information (especially the first link!) I've got a couple of problems that weren't covered in enough detail and questions as to the limitations of what can and can't be done. I'm hoping someone here can help!
I don't know the "techie jargon" to use so will describe things as best I can.. Please bear with me! :)
I am currently blocking certain sites from loading images directly off my site using the following rule in my htaccess file:
=======
# begin rewrite rule to block .gif/.jpg from certain referrers
RewriteEngine on
## add new referrers below this line (include the [OR]!)
RewriteCond %{HTTP_REFERER} firstsite\.com [OR]
RewriteCond %{HTTP_REFERER} lastsite\.com
RewriteCond %{REQUEST_URI} \.(gif|jpg) [NC]
RewriteRule .* - [F]
# end rule
=======
The list is getting too long so I'd like to use it in reverse, blocking ALL sites EXCEPT the ones listed. When I asked my ISP's tech support department how to go about doing this, he sent me this revised version of the same rule:
=======
# begin rewrite rule to block .gif/.jpg from certain referrers
RewriteEngine on
## add new referrers below this line
RewriteCond %{HTTP_REFERER} ! firstsite\.com
RewriteCond %{HTTP_REFERER} ! lastsite\.com
RewriteCond %{REQUEST_URI} \.(gif|jpg) [NC]
RewriteRule .* - [F]
# end rule
=======
I'm a little confused on the new rule. The only difference I notice is adding a ! before the URL and not including the [OR] at the end of each line?
Writing it this way would mean that only requests for image files coming from firstsite.com and lastsite.com would display with all other requests forbidden?
When I asked tech support these same questions, this was his reply:
There's quite a logical difference there, adding NOT (!) and replacing OR with AND (AND is assumed between lines if [OR] is not present.)
It could be read, "If the referrer is neither firstsite.com nor lastsite.com, and the request is for a GIF or JPG file, block the request"
Ummmm... Oooookaaaay.. Logical to whom? I know he doesn't mean "logical" as in "statement"?!?
His reply sounded a little "crisp" if you know what I mean, so I didn't want to keep bugging him. Could someone here please explain the difference in non technical terms?
Questions:
Can I use wildcards? Example: google.* which would allow image requests coming from any google address to be displayed?
What would the format be?
Are there limitations?
Your help is definately appreciated! (poking everyone in the forehead, hoping to tap into all that knowledge!)
Carrie**
I don't know the "techie jargon" to use so will describe things as best I can.. Please bear with me! :)
I am currently blocking certain sites from loading images directly off my site using the following rule in my htaccess file:
=======
# begin rewrite rule to block .gif/.jpg from certain referrers
RewriteEngine on
## add new referrers below this line (include the [OR]!)
RewriteCond %{HTTP_REFERER} firstsite\.com [OR]
RewriteCond %{HTTP_REFERER} lastsite\.com
RewriteCond %{REQUEST_URI} \.(gif|jpg) [NC]
RewriteRule .* - [F]
# end rule
=======
The list is getting too long so I'd like to use it in reverse, blocking ALL sites EXCEPT the ones listed. When I asked my ISP's tech support department how to go about doing this, he sent me this revised version of the same rule:
=======
# begin rewrite rule to block .gif/.jpg from certain referrers
RewriteEngine on
## add new referrers below this line
RewriteCond %{HTTP_REFERER} ! firstsite\.com
RewriteCond %{HTTP_REFERER} ! lastsite\.com
RewriteCond %{REQUEST_URI} \.(gif|jpg) [NC]
RewriteRule .* - [F]
# end rule
=======
I'm a little confused on the new rule. The only difference I notice is adding a ! before the URL and not including the [OR] at the end of each line?
Writing it this way would mean that only requests for image files coming from firstsite.com and lastsite.com would display with all other requests forbidden?
When I asked tech support these same questions, this was his reply:
There's quite a logical difference there, adding NOT (!) and replacing OR with AND (AND is assumed between lines if [OR] is not present.)
It could be read, "If the referrer is neither firstsite.com nor lastsite.com, and the request is for a GIF or JPG file, block the request"
Ummmm... Oooookaaaay.. Logical to whom? I know he doesn't mean "logical" as in "statement"?!?
His reply sounded a little "crisp" if you know what I mean, so I didn't want to keep bugging him. Could someone here please explain the difference in non technical terms?
Questions:
Can I use wildcards? Example: google.* which would allow image requests coming from any google address to be displayed?
What would the format be?
Are there limitations?
Your help is definately appreciated! (poking everyone in the forehead, hoping to tap into all that knowledge!)
Carrie**