.htaccess ReWrite to stop external referrer

Ran into an issue recently where a REALLY old perl script was being used to redirect to an external site that.. well wasn’t work safe.  This script was last up dated in 1999.  Yes.. 1999. as in the year.  Basically the spammer was using this script


Sadly my perl skills are horrible and after four hours of fighting with it I thought .htaccess might be a better option.  After about 20 minutes I had the start of the file and in 30 minutes I had it fixed.  here is what my .htaccess for that directory now looks like.

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://www\.example\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://example\.com/ [NC]
RewriteRule ^ . [R=404,L]

Any one who clicks on a link to that script that does not originate from the domain will now get a 404 error.


After many years I finally got this domain back.  Sadly I do not do much web design any more.  as evidece I present this site, simple wordpress site with a simple free theme.  ( at least for now )

Frankly I am fed up with the direction designers have taken in the past five or so years.  I plan on doing a hand full of posts about some of the annoyances.

I also plan on making new lists of useful sites and guides for new and experienced developers and designers.   Along the way I will either fizzle off and forget about WMO or build a nice set of resources and maybe add a few of my own.