Nginx重写旧版浏览器

我有以下的configuration文件,除了PHP页面的一切工作。

我试图让所有的东西作为一个古老的浏览器添加/ IE /在URL中。 本质上改变这些客户端的根,尽pipe你不能在一个if中设置它。

如果我在PHP位置添加重写也不起作用。 有任何想法吗?

location / { if ($ancient_browser) { rewrite ^(.*)$ /IE/$1 break; } try_files $uri $uri/ /index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_index index.php; if (-f $request_filename) { fastcgi_pass 127.0.0.1:9000; } } 

适用于我(nginx 1.2.3):

  if ($ancient_browser) { set $ab "/IE"; } location / { try_files $ab$uri $ab$uri/ $uri $uri/ /index.php; }