Which rule is right?
filebackup
nginx-forum at nginx.us
Fri Jun 19 13:40:51 MSD 2009
Hi.
I setup some rules in nginx.conf, but I don't known which is right, 1 or 2? Please help me, Thanks.
1,
location ~* .*\.(jpg|jpeg|gif|png|js|ini|css|xml|ico|swf|bmp|html|htm)$ {
if ($http_user_agent ~* baidu|spider {
rewrite ^/ http://www.mydomain.com/robots.txt;
}
if ($http_referer ~* baidu|spider {
rewrite ^/ http://www.mydomain.com/robots.txt;
}
valid_referers none blocked *.mydomain.com;
if ($invalid_referer) {
rewrite ^/ http://www.mydomain.com/error.html;
access_log on;
}
expires 30d;
access_log off;
}
OR
2,
location ~* .*\.(jpg|jpeg|gif|png|js|ini|css|xml|ico|swf|bmp|html|htm)$ {
if ($http_user_agent ~* baidu|spider {
rewrite ^/ http://www.mydomain.com/robots.txt;
}
if ($http_referer ~* baidu|spider {
rewrite ^/ http://www.mydomain.com/robots.txt;
}
expires 30d;
access_log off;
}
location ~* .*\.(jpg|jpeg|gif|png|js|ini|css|xml|ico|swf|bmp|html|htm)$ {
valid_referers none blocked *.mydomain.com;
if ($invalid_referer) {
rewrite ^/ http://www.mydomain.com/error.html;
}
}
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,3114,3114#msg-3114
More information about the nginx
mailing list