Forum Moderators: phranque
I got a site where mod_rewrite is not enable. Starting from a precedent script on an other site where I used mod_rewrite, I wrote this code to ban hot links with my images. Is this code correct?
SetEnvIfNoCase Referer "^$" linked=1
SetEnvIfNoCase Referer "^http://(www\.)?mydomain\.com/.*$" linked=1
SetEnvIfNoCase Referer "^http://(www\.)?myotherdomain\.net/.*$" linked=1
SetEnvIfNoCase Referer "^http://216\.239\.(3[2-9]¦[4-5][0-9]¦6[0-3])\..*(www\.)?mydomain\.com/" linked=1
SetEnvIfNoCase Referer "^http://216\.239\.(3[2-9]¦[4-5][0-9]¦6[0-3])\..*(www\.)?myotherdomain\.net/" linked=1
SetEnvIfNoCase Referer "^http://babel\.altavista\.com/.*(www\.)?mydomain\.com/" linked=1
SetEnvIfNoCase Referer "^http://babel\.altavista\.com/.*(www\.)?myotherdomain\.net/" linked=1
<FilesMatch "\.(gif¦ico¦jpg¦jpeg¦bmp¦wmf¦mid¦rmi¦rm¦ram¦au¦wav¦art¦img)$">
Order Allow,Deny
Allow from env=linked
</FilesMatch>
Your code looks OK to me...
You don't need ".*$" at the end of your patterns, since it is redundant. For example, you can write
SetEnvIfNoCase Referer "^http://(www\.)?mydomain\.com/.*$" linked=1 SetEnvIfNoCase Referer "^http://(www\.)?mydomain\.com/" linked=1 Jim