Forum Moderators: phranque
This is my first time here, and here is my first question.
I was using this script to prevent hotlink for my images, and music file (wma)
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^mysite.com/.*$ [NC]
RewriteRule .*\.(wma名MA妃p3危P3夸pg夸peg夙if如ng在mp)$ mysite.com [R,NC] This would successfully block image files (jpg, gif, bmp) .. but wma or mp3 will not work ..
If they just use direct link on their site then if someone click on it, it will redirect to my site. But if they use this script
<EMBED SRC="link to file.wma" width=300 height=50 AutoStart=true ShowStatusBar=1></EMBED> then it work just fine ..
if I stick this
RewriteCond %{HTTP_REFERER}!^$ in the .htaccess script .. it would block them and as well as my site. I have also use this as well
SetEnvIfNoCase Referer "^mysite.com/" locally_linked=1
SetEnvIfNoCase Referer "^$" locally_linked=1
<FilesMatch "\.(gif如ng夸pe?g安ma妃p3)$">
Order Allow,Deny
Allow from env=locally_linked
</FilesMatch> And still not work.
Can you guy help please. I have lot music file and I found a lot of leecher out there and it's waste my bandwidth alot.
Thank.
Welcome to WebmasterWorld [webmasterworld.com]!
The problem with music files is that most players, notably Windows Media Player, do not provide a referrer. Therefore, you need to block a blank referrer, using ^$ as you show above. But the problem with that is that many legitimate users, such as those behind corporate or ISP firewalls or caching proxies, will also be blocked because the firewall or cache blocks the referrer. It will also be impossible to access the files using a bookmark or javascript.
There is no good solution using referrer-based access control. You can block by IP address, or institute password protection on those files you wish to protect. HTTP_REFERERs are just not reliable enough.
Also, you have a lot of extra characters in your code, and so it can be simplified:
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^(www\.)?mysite.com [NC]
RewriteRule \.(wma妃p3夸pe?g夙if如ng在mp)$ - [NC,F]
If you want to block by IP address use:
RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^192\.168\.0\.1$ [OR]
RewriteCond %{REMOTE_ADDR} ^127\.0\.0\.21$ [OR]
RewriteCond %{REMOTE_ADDR} ^192\.168\.0\.10$
RewriteRule \.(wma妃p3夸pe?g夙if如ng在mp)$ - [NC,F]
Jim
Using REMOVE_ADDR will only block each individual to the file, not the leecher's website IP address right?
I look at the link [httpd.apache.org] you gave me and find instead of use REMOVE_ADDR, can I use HTTP_HOST to block that leecher site?
or how do I block a certain site from access music files a different way than addressed above?
About your questions;
The HTTP_HOST variable contains the name of the server where the requested resource is requested from, usually this is the same as the domain name of your webserver.
The REMOTE_ADDR and REMOTE_HOST variables are acquired from the network connection from the user agent (browser) upon the connection, so it is containing the ip address and the hostname of your visitor.
I would have to vote for a simple authentication scheme that would at least let you control who has access to the files. Even though you have plenty of bandwidth it is still possible for some malicious person to bounce several hundred or thousand requests for the samme file(s) through open proxies and ravage that limit in a very short time.
Then again, I'm paranoid. :)