Forum Moderators: phranque

Message Too Old, No Replies

I need help.

With .htaccess

         

sergio

11:22 pm on Jun 2, 2004 (gmt 0)

10+ Year Member



Ok guys, I own <snip> and I host videos of games. However I have another website trying to steal that media. So I need help with soemthing. This is what I have in my .htaccess

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]

jdMorgan

1:11 am on Jun 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sergio,

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]

However, with the exception of the correction to your filetype pattern, the behaviour of this code will be identical to what you already have, just faster.

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

sergio

3:57 am on Jun 3, 2004 (gmt 0)

10+ Year Member



Sorry for posting my site url. Ok Jim I did that. I deleted all of my cache files and put that code into my .htaccess. However now everyone seems to be able to access it. I tried putting it on the address bar and it works, tried on AIM and you still can see the video. Could anyone else help me?

jdMorgan

5:12 am on Jun 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sergio,

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>

This will force all caches to check with your server before returning locally-cached content.

Jim

sergio

5:37 am on Jun 3, 2004 (gmt 0)

10+ Year Member



Jim again thanks for all the help. However it's not only me, everyone can access it, I have cleared my cache on every single test and I have asked the other people to do so too, and they can still access it.