View Full Version : The black art known as htaccess
Skyzyx
12-10-2005, 05:27 AM
I've been working with this block of code for the last three hours, and it's just not working. I am beyond stumped. Can anybody help me figure out why this isn't working:
RewriteCond %{HTTP_REFERER} !^http://(www\.|backend\.|blog\.|bugzilla\.|downloads\.|labs\.|support\.|university\.|wishlist\.)?(skyzyx|sim plepie|ryanparman)\.(com|net|org)/ [NC]
RewriteCond %{HTTP_REFERER} !^http://feeds\.feedburner\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(asf|bin|(b|g)z2?|divx|dmg|exe|gif|hqx|jar|jpe?g|m4v|mov|mp2|mp3|mpe?g|msi|pdf|png|rm(a|v)?|sit|sw f|tgz|torrent|txt|wal|wm(a|v)|wsz|xpi|zip)$ - [F,L]
I should clarify that I want any of a number of subdomains (www, backend, blog, downloads, etc.) for the domains skyzyx.com, skyzyx.net, skyzyx.org, simplepie.org, and ryanparman.com to be able to access the files, but nobody else (except for the Feedburner service).
hyperbole
12-11-2005, 06:06 PM
Try simplifying your rules. Something like this
RewriteCond %{HTTP_REFERER} !^http://feeds\.feedburner\.com/ [NC]
RewriteRule \.html$ - [F,L]
Get that to work, then add in the other conditions
Should you be using HTTP_REFERER? I would think you should be using REQUEST_URI.
.
Except from the redundant L flag, I couldn't see anything wrong, so I used your first RewriteCond and RewriteRule in an existing .htaccess, added another domain name in the condition and everything worked fine. No errors, no hotlinking. So it seems you have working code.
Are there other rewrites in your .htaccess? Is mod_rewrite enabled? Did you empty your browser cache before testing any change?
And maybe I shouldn't ask, but if this is the only rewrite you have - you did turn the thing on, didn't you?
RewriteEngine On
vcorp
12-12-2005, 02:24 PM
take a look here
http://www.risorse.net/apache/aut_ctrl_accessi_web.asp
if u know italian language!!!!
Skyzyx
12-13-2005, 05:23 PM
Well, it seems as though the rules are blocking direct links to the files, which is a plus. The big issue is that people are embedding my videos into their sites. It seems to block Flash embedding, but for some reason isn't blocking WMV and MOV embedding. Any thoughts?
Windows Media Player doesn't send a referrer I believe. And since you're allowing blank referrers (which you should), I'm guessing there's not much you can do about that (other than renaming them every two days..).
[ Added: On the other hand, with zillions of hotlinked videos on the web I'm sure there must be more than one solution. Cookies, maybe.. ]
Skyzyx
12-13-2005, 06:39 PM
Well, between here and a few other suggestions, I think I'm going to do the following:
Build my own file browser system from scratch (as opposed to continuing to use the one I have been), that will support sessions/cookies (must have visited my site to view the files), as well as obfuscating the direct urls for the files, so that they have to go through a specific "special" url, which will change every couple of days, all in tandem with keeping these rules, and maybe adding one that either blocks WMP from streaming them, or convert all video away from WMV format.
If it's good enough, I may even release it as a software package down the line. :)
Thanks for the suggestions, all. My 30-day cycle started over yesterday, so the site is back up for now.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.