Categories
blog

Gating a directory

A short while ago, I noticed that there was some schmuck from Russia linking me to a gallery of theirs. What they did was capture my gallery site inside an iframe and showed it off as theirs. Those rat bastards took a couple of GB of traffic last month alone! Luckily, I have plenty to spare, so I wasn’t charged extra for that unusual spike in bandwidth consumed.

Obviously, that pissed me off a little, so I worked a little mod-rewrite magic. I could have easily written a javascript to bust out of the frame, but I didn’t want to have any part of that. Personally, I believe there should be no reason whatsoever for anyone to directly link to my gallery without my permission. As such, I fudged a little rewrite snippet to prevent anyone but me (well, some of my domains) to directly link to my gallery.

Obviously, if you want to use this on your site to prevent people from linking to a specific area, be very careful about it. Just drop it in your .htaccess file for the specific directory that you want to gate. I realize I’ll shut search engines out of that particular area, (I think) but I can care less about a Google Rank. Also, I never really tested this, so I am not entirely sure it will work. So far, I can’t link to this site from any of my other domains not specified, but I’m sure this can be circumvented. If anyone can help to harden this, please drop a comment. I’ll have to admit, I’m a hardcore n00b when it comes to mod_rewrite. 🙂

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://somerisebysin.org.*$ [NC]
RewriteRule .*$ - [F,NC]

2 replies on “Gating a directory”

Let me tell you a little mod_rewrite story.
I had a few funny car related pictures hosted on my site. Somehow, they ended up being posted on a bunch of car forums (non-English speaking no less). So I did a littel mod_rewrite so that the picture became Goatse instead. Couple of days later I realized I was banned from some random webcomic forum I visit. I had forgotten that my image sig was shown there and didn’t add their domain – so I Goatse’d the forum 🙁

Comments are closed.