Valid_referers problem

I am using valid_referers to detect image hotlinking. Invalid referers
are forwarded to the homepage, however, I have since changed the address
for images from images.hollywoodgrind.com:9000 to
www.hollywoodgrind.com.

The last line contains the rewrite rule ‘rewrite ^
http://www.hollywoodgrind.com$request_uri? permanent;’, which would
forward traffic going to images.hollywoodgrind.com:9000 to it’s new
exact location at www.hollywoodgrind.com.

What I’d like is for invalid traffic to be forwarded to the home page
located at www.hollywoodgrind.com, but for valid traffic to be forwarded
to the new url location for the image.

I am not sure that the block of code below is working as I intend.

server {
listen 9000;
server_name images.hollywoodgrind.com;
location /images {
valid_referers blocked ~.google. ~.yahoo. ~.bing. ~.ask.
~.live. ~.googleusercontent.com. www.hollywoodgrind.com
hollywoodgrind.com
hollywoodgrind.com images.google.com 209.85.171.104
google.com www.google.com yahoo.com my.yahoo.com
feedproxy.google.com/HollywoodGrind images.search.yahoo.com live.com
search.live.com 209.85.173.132 ask.com images.ask.com
translate.googleusercontent.com googleusercontent.com bing.com;
if ($invalid_referer) {
rewrite ^(.*)$ http://www.hollywoodgrind.com/;
}
rewrite ^ http://www.hollywoodgrind.com$request_uri? permanent;
}
}

try
valid_referers blocked none allowed.dominian.tld;

2010/10/23 Todd HG [email protected]

On Sat, Oct 23, 2010 at 10:06:27PM +0200, Todd HG wrote:

What I’d like is for invalid traffic to be forwarded to the home page
hollywoodgrind.com images.google.com 209.85.171.104
google.com www.google.com yahoo.com my.yahoo.com
feedproxy.google.com/HollywoodGrind images.search.yahoo.com live.com
search.live.com 209.85.173.132 ask.com images.ask.com
translate.googleusercontent.com googleusercontent.com bing.com;
if ($invalid_referer) {
rewrite ^(.*)$ http://www.hollywoodgrind.com/;
}
rewrite ^ http://www.hollywoodgrind.com$request_uri? permanent;
}
}

server {
listen 9000;
server_name images.hollywoodgrind.com;

location / {
    rewrite ^ http://www.hollywoodgrind.com$request_uri? permanent;
}

location /images {
    valid_referers  blocked
                    ~\.google\.
                    ~\.yahoo\.
                    ...
                    googleusercontent.com
                    bing.com
                    ;

    if ($invalid_referer) {
        rewrite  ^  http://www.hollywoodgrind.com/?;
    }

    rewrite ^ http://www.hollywoodgrind.com$request_uri? permanent;
}

}


Igor S.
http://sysoev.ru/en/

Thank you Igor.