question regarding referers

Stefanita Rares Dumitrescu katmai at keptprivate.com
Wed Apr 30 09:59:48 MSD 2008


Roxis wrote:
> On Tuesday 29 April 2008, Stefanita Rares Dumitrescu wrote:
>   
>>         location ~*
>> ^.+.(jpg|jpeg|gif|css|png|js|ico|flv|txt|zip|mp3|rar|w3x)$ {
>>                 if ($invalid_referer)
>>                 {
>>                    #return 403;
>>                    rewrite / http://www.mysite.com/;
>>                 }
>>                 root              /home/account/public_html;
>>                 expires           30d;
>>         }
>>
>>
>>
>> the problem is that if the extension is changed, for example JPG or JpG,
>> the location regex  does not work. it's case sensitive.
>>     
>
> it should work, but isn't 100% correct.
> backslash before second dot is missing.
>
> do you have any other locations before this one?
>   
Yes, this is the full location directive.

        location     / {
            root     /home/account/public_html;
            index    index.html index.htm index.php;
        }

        location ~* 
^.+.(jpg|jpeg|gif|css|png|js|ico|flv|txt|zip|mp3|rar|w3x)$ {
                if ($invalid_referer)
                {
                   #return 403;
                   rewrite / http://www.domain.com/;
                }
                root              /home/account/public_html;
                expires           30d;
        }






More information about the nginx mailing list