我在网上查了,简单的有两种location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {
valid_referers none blocked *.abc.com abc.com;
if ($invalid_referer) {
#rewrite ^/ http://www.abc.com/404.html;
return 403;
}
}
location /img/ {
root /data/img/;
valid_referers none blocked *.abc.com abc.com;
if ($invalid_referer) {
rewrite ^/ http://www.abc.com/images/error.gif;
#return 403;
}
}其中location放在 http -> server 里http{
server{
location ... }
}可是为什么我这样设置后我的整个网站都上不去了?打开首页就指向404了,为什么?
谢谢大家
valid_referers none blocked *.abc.com abc.com;
if ($invalid_referer) {
#rewrite ^/ http://www.abc.com/404.html;
return 403;
}
}
location /img/ {
root /data/img/;
valid_referers none blocked *.abc.com abc.com;
if ($invalid_referer) {
rewrite ^/ http://www.abc.com/images/error.gif;
#return 403;
}
}其中location放在 http -> server 里http{
server{
location ... }
}可是为什么我这样设置后我的整个网站都上不去了?打开首页就指向404了,为什么?
谢谢大家
我知道abc要改成我的网站的域名,我改成了我的网站的域名了,然后我的整个网站都打不开了。。
如果是你发的第一种方式,尝试把location放在你正常的location之后,location的顺序很重要。