我正在遵循http://wiki.nginx.org/HttpBrowserModule教程。
我有以下configuration。
ancient_browser "MSIE 6.0"; if ($ancient_browser){ rewrite ^ /ie6; }
这个问题是我得到一个无限循环。
我如何使它工作!? 我很惊讶,即使是官方文档的例子。 不起作用。
更新:
我目前的代码
server { listen 83; server_name {my ip goes here} location / { ancient_browser "MSIE 6.0"; if ($ancient_browser){ rewrite ^ /ie6 break; } proxy_pass http://localhost:34881 ; proxy_set_header Host $host ; proxy_set_header X-Real-IP $remote_addr ; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ; proxy_set_header Country $geoip_country_code; proxy_cache cache; proxy_cache_valid 200 302 1h; proxy_cache_valid 404 1m; add_header Pragma no-cache; expires epoch; if_modified_since off; add_header Last-Modified ""; }
更新2:
我想出了以下的代码片段,它的工作原理。
if ($http_user_agent ~ "MSIE 6.0") { set $IE T; } if ($uri != "/ie6/") { set $IE "${IE}RUE"; } if ($IE = TRUE) { rewrite ^ /ie6 break; }
如果有人有更好的解决scheme,请发表评论..谢谢!
尝试使用$http_user_agent来代替:
if ($http_user_agent ~ "MSIE 6.0" ) { rewrite ^ /ie6 break; }
或者看看这个话题。
添加break :
rewrite ^ /ie6 break;
这个例子的意图可能是configuration不适用于你正在重写的位置。
您需要确保将用户redirect到configuration的一部分,而这部分configuration不是由相同的规则处理的。
有没有像这样的工作,也许?
location ^/ie6 { break; }