Forum Moderators: DixonJones
RewriteEngine On
RewriteCond %{HTTP_REFERER}!^http://yoursite.com/ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.yoursite/ [NC]
RewriteRule [^/]+.(gif¦jpg¦mp3)$ http://www.yoursite.com/pics/denied.gif [R,L]
I was playing around with this earlier this year to nail down some issues that arise from using .htaccess protection that you should be aware of. (1) Frames present a problem for Netscape users trying to view pages with images protected in this manner. Netscape does not supply a referer value in its http request for an image on a framed page, and so Apache will not recognize it as coming from your site and will deny access. This applies to Netscape v4.x through v7.x, and may well apply to Mozilla (which I didn't test) and other browsers. MSIE substitutes the URL of the parent <frameset> page. (2) If you create a pop-up window with a call to the JavaScript function window.open and you do not supply a source URL that points to a real page on your site, http requests for image files within this window will usually be denied. However, the simple work-around is to create a shell .html file, load it into the pop-up via window.open, and then use JavaScript to fill in the page contents as desired.