答案 0 :(得分:1)
您正在寻找类似map指令的内容。以下示例基于https://serverfault.com/questions/316541/check-several-user-agent-in-nginx
http {
map $http_user_agent $ua_redirect {
default '';
~(iPhone|Android) m.domain1.com;
~(MSIE|Mozilla) domain2.com;
}
server {
...
location / {
...
if ($ua_redirect != '') {
return 301 http://$ua_redirect$request_uri;
}
}
}
}