26 Jun 2007 @ 11:09 PM 
 

How To > Use .htaccess to screw over a hotlinking asshole

 

Ok, so with my page it’s not just images people try to link to, it’s entire pages. Why? Because a lot of them look pretty damn good as stand alone pages and are just much easier to work with inside iframes.

So I saw this guy in my statistics that was hotlinking directly to my Sega Genesis and Nintendo pages. Well that really pissed me off because it took me a LOT of time to put those bloody games on there. If you want the NES on your page, you can download it yourself. If you want the Sega Genesis on your page, well there you are kind of screwed, since it is licensed and the guys who made it promised me updates and then disappeared like a fart in the wind. Anyways, this is getting off the subject.

I looked around and only saw ways to prevent hotlinking to image files, pages seemed a little more obscure. So I figured I would write it up. We will use the asshole who did it to me as an example.


RewriteEngine on # I had this on earlier in my htaccess, but if you didn’t you will need to add it to rewrite anything.
#RewriteCond %{HTTP_REFERER} ^http://([^/]+\.)?baddomain1\.com [NC,OR] #Uncomment this line if you have more than 1 asshole linking to you, and copy it if you have several.
RewriteCond %{HTTP_REFERER} ^http://([^/]+\.)?aw3bo\.net [NC] #This says look to aw3bo.net (NC = Non case sensitive)
RewriteRule \.(php|htm)$ http://www.thesmartass.info/hotlink.html [R,L] #This says if he links to my pages to force him to my hilarious hotlink page..

Basically my actual pages are never named anything but php or htm, so this will make all my actual pages that he links to force him to see my hotlink page. Be careful, I screwed this part up at first… All requests coming from his site asking for .php or .htm are getting redirected.. So you have to name your file extension you link to something different. I eventually went with .html

It’s much more entertaining than sending them to just an image. Originally my hotlink page did a meta refresh after 10 seconds, but then I noticed that my page still looks good even in a tiny frame since the images are proportional etc… So I removed that for just an old fashion giant link under the probably offensive image.

You can modify the rule where it says php|htm to add additional extensions by adding more pipes jpg|gif|png etc.. But if you redirect an image make sure that you are redirecting them To an image…

Some other nasty things you can do to the people you dislike in .htaccess include:


#Redirect IP’s Somewhere Else
RewriteEngine on
RewriteCond %{REMOTE_ADDR} 2.21.1.19 [OR]
RewriteCond %{REMOTE_ADDR} 70.200.40.157
RewriteRule /* http://www.uglypeople.com [L]


#Just straight up block users from accessing the site… not quite as fun but still useful
order deny,allow
deny from 80.76.55.21
deny from .spammers.com
allow from all

UPDATE 7/16: People seem to keep doing this. Stop it Mo-Fo’s… I have been researching the .htaccess more and have found a way to simplify the rewrites to use a lot less code, and much less confusing syntax.

#Hotlinking Assholes
RewriteCond %{HTTP_REFERER} (aw3bo|spotlightarcade) [NC]
RewriteRule \.(php|htm)$ http://www.thesmartass.info/hotlink.html [R,L]

Notice that now I have 2 different sites listed, separated by a pipe and inside (). That’s it. I don’t need to put the exact syntax or even the .com’s etc.. anymore… If you are refered to me by a site with that info, you get zapped to my screw you / meatspin page.

UPDATE 7/19: Here’s a rule I just changed. I have been adding TONS of rules to prevent overall nasty people from being on my site. Now I had these guys redirecting to “-” but that just sends them to my 403 page… Screw that, Instead I have decided that from now on I shall be updating my rule to link to the most recent hotlinker. So all of my crappy traffic will get sent to the people who are trying to steal traffic from me to begin with. Below is the current rule, remember there are countless RewriteCond before the actual rule, if you try to add this rule without a condition you will send all your traffic there…

#sends all my shitty traffic to most recent hotlinker
RewriteRule /* http://www.spotlightarcade.info/sega/ [L]

Return to The SmartAss DOT Info

Tags Categories: Internet, Web Design Posted By: Jamez
Last Edit: 19 Jul 2007 @ 10 12 PM

EmailPermalink
  • Heh, yeah I am considering setting up an entire revenge page and making the script rotate the nasty content that they see.

    Thanks for the XHTML note, it's hard to always keep everything validated on a Wordpress blog. Typically all my pages do but i've been so busy with making changes to the site lately to keep up on the validation. I figure if it works I can check it later.
  • Dave
    Love the hotlinking idea. Really got a kick out of visiting the sites that have hotlinked to you. Ha!

    FYI - Your XHTML doesn't validate when the link is clicked on the bottom of the page. CSS does, though.
blog comments powered by Disqus
\/ More Options ...
Change Theme...
  • Users » 110
  • Posts/Pages » 61
  • Comments » 220
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight