Forum Moderators: phranque
I am new to this forum, please help me to solve my probelm. For protecting hotlinking of my video files, i added these lines to the .htaccess file, but after that im unable to play the videos on my own site. I dont know what i am doing wrong in this, please help me to solve this issue. I am losing lot of my bandwidth because of this.
RewriteEngine On
RewriteCond %{HTTP_REFERER} [domain.net...] [OR,NC]
RewriteCond %{HTTP_REFERER} [domain.net...] [OR,NC]
RewriteRule .*.(rm¦wmv¦avi¦mp3)$ [mydomain.net...] [R,NC]
Thanks in advance for your help
Welcome to WebmasterWorld.
The immediate problem is the second OR in your conditions... (Not sure why there are two, they are redundant.)
Then as noted above, you should check for a blank referrer. (!=is not ¦ .(dot)=any character except the end of a line)
For efficiency, it is better to use the impicit 'everything up to' by removing the start anchor from the rule, or use a negative pattern match -- not .* if it can be avoided. (EG [^.]+ = any thing that is not a .(dot))
RewriteEngine On
RewriteCond %{HTTP_REFERER} !. [OR]
RewriteCond %{HTTP_REFERER} http://domain.net [NC]
RewriteRule ^[^.]+\.(rm¦wmv¦avi¦mp3)$ http://www.mydomain.net/cms [NC,R=301,L]
Finally, R=Undefined Redirect (302), so it is better to set the flag as either Permanent (301) OR Temporary (307) -- using the L (Last) flag will also save you some processing.
Hope this helps.
Justin
BTW An empty referrer will be redirected in the above ruleset -- to force an empty referrer to not be redirected, remove the ! and the [OR]
Thanks all of you for your replies,
I have norton internet security 2005 and windows firewall installed on my system.
now i changed rule like this with out HTTP_REFERER, still i am unable to see my videos on my system, may be the security programs are blocking. Please advice me if the rewrite rule is correct.
RewriteEngine On
RewriteCond %{}!. [OR]
RewriteCond %{} [domain.net...] [NC]
RewriteRule ^[^.]+\.(rm¦wmv¦avi¦mp3)$ [mydomain.net...] [NC,R=301,L]
Thanks for your help
The last code you posted is invalid, and I'm surprised you did not get a 500-Server Error when it was invoked.
*IF* a request is redirected to /cms/, how does /cms/ know what content to serve? Is this a script that examines the client request header to get the originally-requested filename, or what?
If the request is *not* referred from your own site(s), what do you expect to happen?
Jim
sorry for my english and my poor explanation.
I have some video files on my website for my users. When i checked my log files i found that in some public forums people posted links to these files, so that visitors of that sites can download directly with out knowing that they are doxnloadinf from my site and they will not come to my site.
I want to prevent this, in google i found mod rewrite rules from this site [modwest.com...]
i added these lines to my .htaccess file. I dont know anything about these rules and how they will work.
RewriteEngine On
RewriteCond %{HTTP_REFERER} [domain.net...] [OR,NC]
RewriteCond %{HTTP_REFERER} [domain.net...] [OR,NC]
RewriteRule .*.(rm¦wmv¦avi¦mp3)$ [mydomain.net...] [R,NC]
But after this iam unable to see these videos on my own site; iam getting errors.
Now i want to write a rule so that users from my site will be able to see the files and if somebody from other sites refer to these they should get an error message or they should be redirected to my home page.
I am using xoops cms 2.2.3 and i installed it in /cms folder
I hope i am clear now, if anything missing please let me know.
Thanks in advance for your time.
[edited by: jdMorgan at 2:27 pm (utc) on Nov. 21, 2005]
[edit reason] No URLs, please. See TOS. [/edit]
If so, then the only problem I see is that you have an [OR] flag on your second RewriteCond. This is a logical error and a syntax error, since only RewriteConds can be ORed.
So try this first:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?domain\.net [b][NC,OR][/b]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?domain2\.net [b][NC][/b]
RewriteRule \.(rm¦wmv¦avi¦mp3)$ http://www.domain.net/cms [R,NC]
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?domain\.net [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?domain2\.net [NC]
RewriteRule \.(rm¦wmv¦avi¦mp3)$ /cms [NC]
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim