Domanda

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

È stato utile?

Soluzione

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;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top