exclude invalid_referrer directory

Todd HG lists at ruby-forum.com
Sat Jan 1 06:58:33 MSK 2011

I use the following code block to redirect invalid referrers back to the
homepage when someone attempts to view an image directly on my Wordpress

I would like to be able to use /var/www/blog/wp-content in the code
block below for the invalid referrers, and have another code block such
as /var/www/otherimages that does not redirect or block any referrers.
/var/www/otherimages could be viewed by anyone even directly. How would
I write this second code block?

location ~ \.(jpg|jpeg|gif|png|flv|mp3|mpg|mpeg)$ {
root    /var/www/blog;
expires max;
valid_referers blocked ~\.google\.;
if ($invalid_referer) {
rewrite  ^(.*)$  http://www.mydomain.com/;

Posted via http://www.ruby-forum.com/.

More information about the nginx mailing list