Htaccess / hotlink prevention / nowww!


#1

From the amazing Dreamhost Wiki, I find that I can put this:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www.)?example.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .(jpe?g|gif|png)$ - [F]

into my htaccess to prevent hotlinking. What I’d like to know is, does it make any difference if you are using all non www sites (the example.com above has the www) and if so what should be changed?


“Whenever you find yourself on the side of the majority, it’s time to pause and reflect.” - Mark Twain


#2

code?[/code]? is 0 or 1 of the preceding text.
(text) groups the text together
\char escapes the ., which is a special character

So that part of your regular expression says that there may or may not be a www. between the “http://” and the “example.com” part of the url.

Free unique IP and $67 off with code [color=#CC0000]LMIP67[/color] or use [color=#CC0000]LM97[/color] for $97 off. Click for other Dreamhost coupons / promo codes


#3

Ahhh… once again, thank you Lensman!

Now if only there were a way to block ALL of China from one of my sites! Why they index me into crappy and downright strange portals over there I just don’t understand.


“Whenever you find yourself on the side of the majority, it’s time to pause and reflect.” - Mark Twain


#4

Maybe they just love all your content and want “all your pages are belong to us” :wink:

-rlparker