location /{
if ($remote_addr=192.168.1.100){ //禁止此 ip 访问
return 403;
}
root /usr/local/html;
index index.html index.htm;
}
location /{
if ($http_user_agent ~ MSIE){ //如果使用的是 ie 浏览器【 access.log 里有浏览器的头信息】
rewrite ^.*$ /ie.html //无论访问那个页面 都让他重写到根目录下 的 ie.html
break; //不加 break 会一直匹配到这里形成死循环。
}
root /usr/local/html;
index index.html index.htm;
}
location /{
if (!-e $document_root$fastcgi_script_name){ //如果访问页面不存在
rewrite ^.*$ /404.htm; //将被重定向到 404 页面
break;
}
root /usr/local/html;
index index.html index.htm;
}
location /{
if ($http_user_agent ~* msie){ //如果访问者使用的 ie 浏览器
set $isie 1;
}
if ($fastcgi_script_name=ie.html){ //如果访问的是 ie.html
set $isie 0;
}
if ($isie 1){ //如果是 ie 浏览器且不是访问的 ie.html,重写到 ie.html
rewrite ^.*$ ie.html;
}
root /usr/local/html;
index index.html index.htm;
}