Forum Moderators: phranque
Rewriteengine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.mydomain.com/.*$ [NC]
RewriteRule .*.(*)$ - [F]
I tried the below code & it seems to work fine; but not sure if it's correct (I'm still a noob @ RegEx).
Rewriteengine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://mydomain\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.mydomain\.com/.*$ [NC]
RewriteRule .*\..+$ - [F]
I'm trying to prevent the hotlinking of files btw..
Thanks!
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
RewriteRule \.(jpg¦gif)$ - [F]
You should be specific about *what* files you don't want hotlinked. I show the common version above, which covers jpg and gif filetypes only. If you need to add more, just put them in the parentheses separated by a solid pipe character. Note that you'll need to change the pipe in this code to a solid pipe before using it; Posting on this forum modifies that character.
Jim
Besides, trying to protect your site from hotlinking is fairly pointless. Referrers can be spoofed \very\ easily, and lots of browsers never send the referrer with them in the get request.
Any file? That means if someone links to your site other than yourself, the visitors will get an error and not the desired page.
No; I'm only applying it to a certain directory & it's subdirectories.
As for the referrer isue; yes, I'm aware of that.. I'm putting other safeguards in place also; this is just one of them. :)
RewriteRule .* - [F]
Jim
Would this suffice?
RewriteRule /userfiles/.* - [F]
Can't really put it into the folder as I'm having issues with other code & makes it a lot easier if I can put it all in the root .htaccess file.
Thanks again!