ModRewrite for resources protection.

Discussion in 'Apache' started by lagrange, Feb 14, 2008.

  1. #1
    Hi all,
    I have a need: in my site there are Flash's contents that I would like to display only within my pages and I want to prevent that there may be direct links from other sites or, worse, that someone can download it with programs such as GetRight.
    Is it possible? I tried with this .htaccess:


    RewriteEngine On

    RewriteCond %{REQUEST_URI} \.(gif|jpe?g|png|swf)$ [NC]
    RewriteCond %{REMOTE_REFERER} !^$
    RewriteCond %{REMOTE_REFERER} !(192\.168\.0\.3.*)
    RewriteCond %{REMOTE_REFERER} !(mysite\.com.*) [NC]
    RewriteRule (.*) /error.html

    and it's ok for web browsers. But if I use GetRight, I can download the contents 'cause the htaccess see that the "remote_referer" is empty then I should to delete the "RewriteCond %{REMOTE_REFERER} !^$ " but if I do this I get a problem with web browsers (cause sometimes they send to web server a empty remote_referer field :mad:).
    How I can resolve the problem? :confused:

    Thank you very much, :)

    Luca.
     
    lagrange, Feb 14, 2008 IP