Mad, Beautiful Ideas
Blocking 'Domain Smacks' in Apache

Recently, some intrepid person decided to buy uwrejects.com and have it show Washington State University's website. Frankly, I thought it was pretty amusing, but there were a fair number of concern by certain executives at the institution. However, it did seem to remind me of the concept, of the "Domain Smack"

Alright, sorry for the ad (I'm not even getting paid for that), but it explains what the hell a domain smack is.

So, what do you do when some jokester decides to domain smack you, and you (or your boss) is really concerned with it? Just a few rules with mod_rewrite, and you'll be fine, on Apache at least. IIS and other servers can do this as well, and IIS can even import Apache mod_rewrite rules easily.

        RewriteEngine on
        RewriteCond %{HTTP_REFERER} smackingdomain.com
        RewriteRule .+ [F] # Return 403 Forbidden
        RewriteRule .+ http://jokestersite.com/ [R] # Redirect back on the joker.
        

The syntax is fairly straightforward. Turn the RewriteEngine on (if you haven't used it yet in the .htaccess file), check the Referer header (which is misspelled in the specification) for the smackingdomain, then rewrite ANY URL (the .+) to either return forbidden or redirect back at whomever has decided to make fun of you.

At the end of the day, WSU is seriously considering doing nothing. Which is good, because it's better to have a sense of humour about such things. However, good mastery of conditional URL Rewriting rules are good to have, and I'll probably do some more advanced stuff with it later, since the documentation lacks a lot of examples which could be really nice to play with.