rewrite rules

Roxis roxis at list.ru
Fri Jan 25 15:31:45 MSK 2008


On Friday 25 January 2008, Stefanita rares Dumitrescu wrote:
> Stefanita rares Dumitrescu wrote:
> > hi guys,
> >
> > can anyone please translate for me the below rewrite rules? regex and
> > rewrite is not my best quality unfortunately :( i know about rtfm ...
> > but it's just a thing that doesn't stick with me.
> >
> > RewriteEngine on
> > RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain1.net [NC]
> > RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain2.net [NC]
> > RewriteRule \.(zip|mp3)$ - [NC,F,L]
>
> RewriteCond %{HTTP_REFERER} !^$
> RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$      [NC]
> RewriteCond %{HTTP_REFERER} !^http://domain.com$      [NC]
> RewriteCond %{HTTP_REFERER} !^http://www.domain.com/.*$      [NC]
> RewriteCond %{HTTP_REFERER} !^http://www.domain.com$      [NC]
> RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.domain.com [R,NC]
>
>
> in case anyone is wondering what is this, it's hotlinking protection.
> i can do anything else but rewrite :)


server_name domain.com www.domain.com;

valid_referers none blocked server_names;

location ~* \.(zip|mp3)$ {
    if ($invalid_referer) {
        return 403;
        #rewrite / http://www.domain.com/;
    }
}





More information about the nginx mailing list