Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com/ [NC]
RewriteRule \.(gifŠjpgŠpng)$ /img/no.$1 [L]
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com/ [NC]
RewriteRule \.(cgiŠphp)$ - [F]
Now... that should block any "hotlinkers" access to my graphics or scripts. But it when I load the home page I don't get any graphics :(
So, obviously something is wrong. I just can't figure out why...
Several possibilities:
Try removing the trailing slash from "example.com" in the RewriteConds.
"example.com" must be your own domain.
Your browser may have cached the server response after you tested from a "foreign" domain.
If any subsequent redirects are processed (in lower-level directories, for example), you will have to explicitly allow access to the substitute image files in /img/no.gif, etc. by adding another RewriteCond.
Otherwise, your code looks fine.
Casual readers, please note that this board deletes spaces preceding exclamation points. These spaces are required in mod_rewrite. So, for example, the second RewriteCond above should read:
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com [NC]
HTH,
Jim