Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Detect domain and device and redirect

$
0
0
Hello

I would like to detect the device from with nginx and route to a specific root or folder of the index.html, my configuration is the following :

server {
listen 80 default_server;
server_name ~^(www\.)?(?<domain>.+)$;

location = /index.html {
if ($http_user_agent ~* '(iPhone|iPod|iPad|Android|BlackBerry|webOS|Windows Phone)') {
root /home/folder/abc;
}

if ($http_user_agent !~ '(iPhone|iPod|iPad|Android|BlackBerry|webOS|Windows Phone)') {
root /home/folder/xyz;
}
}
index index.html;
}

it gives me a page 404 error.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>