Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^$ [OR]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite\.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite\.com/.*$ [NC]
RewriteRule .*\.([wmv¦mov¦asf¦asx]+)$ - [NC,F]
However that works since it can't be access from anywhere outside my website or putting the address in the address bar.
However when I put a link like [mysite.com...]
so when I put that link on my forums (http://mysite.com/forums/) is doesn't work and it blocks me. I have tried adding [mysite.com...] to the .htaccess but still no luck.
[edited by: jdMorgan at 1:02 am (utc) on June 3, 2004]
[edit reason] Removed specifics per TOS [/edit]
Welcome to WebmasterWorld [webmasterworld.com]!
We don't post our personal site URLs here; Please see our Terms of Service and the Forum Charter.
Your code can be simplified to:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite\.(net¦com) [NC]
RewriteRule \.(wmv¦mov¦asf¦asx)$ - [NC,F]
The most likely cause of this problem is that the 403-Forbidden response has been cached by your browser; Flush your browser cache (and proxy cache, if applicable) before testing each mod_rewrite change.
Also, change the broken pipe "¦" character in the code above to a solid pipe before use -- posting on this forum modifies them.
Jim
You will need to flush your cache before *each* test. If the file is in your cache, your browser will not send the request to your server, so your .htaccess code won't have a chance to block the request. The same is true if your ISP and/or your company uses a caching proxy -- If the file is in any cache between your computer and your server, then the request will not be sent to your server; the content will be returned from the cache instead. The code is good, and will block any request received by your server with a referer that is not one of your valid domain name variants, so something else is wrong.
You may wish to set "no-cache, must-revalidate" in the server headers returned with these files.
<FilesMatch "\.(wmv¦mov¦asf¦asx)$">
Header unset Cache-control
Header append Cache-control: "no-cache, must-revalidate"
</FilesMatch>
Jim