Hm. In my Googling I haven’t been able to find a precise answer to this:
For anti-leeching, you can deny access to a specified linking URL, refusing access/traffic that is coming from links at the Evil URL.
Okay, cool. I’ve implemented that before.
What about the other way around, as in denying everyone except the one linking URL?
Example/
If there was a section of my website that I visitors only to be able to access from links on my own site - no direct requests, no external links - to view the material you must be coming through a link on my page.
Sort of instead of: deny from env=BadReferrer
having something like: allow from env=GoodReferrer
Is this doable with htaccess or is it ridiculous and would cause too many failures depending on the browser?
Just curious.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com [NC]
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com [NC]
RewriteRule /* http://www.yourdomain.com [R,L]
This will redirect any traffic not coming from your domain to your front page
Interesting. So this also prevents direct request (typing the address in the location bar) because it restricts the access to the one referrer only?
Very cool. I didn’t expect it to be so easy. I thought it might boggle up some basic browser requests. Thanks!
I’m gonna make a dummy page and play with it a bit! I’m curious to know how it would affect things like streaming media and file downloads like PDFs.
I have no real practical need for it, but it’s good to know for future reference… In case I ever need to go top secret and be 007 Eats_Bonds.
Thanks again!
You should also know that not all browsers forward the HTTP referrer. Opera, for example, can be configured to disable it. Anonymizing software may also block it.
Thanks for the input.
That was the worry I voiced in my OP - that it might produce some kind of “bad request errors” of some kind depending on the browser. I’m also suspecting it could cause glitches that affect files that are accessed by another software program or fancy schmancy plug-ins like media players or PDF readers (not quite sure how those call on the file).
In any case, my work day is expcted to be slow, so I’ll goof with it to see what happens.
Thanks for the warning. Htaccess can be pretty cool, but alas it has very pesky limitations. Fun to play with though.