Question

I need to redirect users to specific page if their user-agent is not WebKit family. Is it possible to do by using nginx?

Était-ce utile?

La solution

Yes, you can use the $http_user_agent variable to check against it

set $webkit_rewrite do_not_perform;

## http_user_agent for webkit ##
if ($http_user_agent ~* WebKit) {
  set $webkit_rewrite perform;
}

## redirect to webkit.example.com ##
if ($webkit_rewrite = perform) {
  rewrite ^ http://m.example.com$request_uri? redirect;
  break;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top