I want to use a different home page for visitors using czech language. I found similar questions (#1, #2), I read nginx manual but I cannot make it work. It always serves a default index.html instead of index-cs.html.
map $http_accept_language $lang {
default en;
~*cs.* cs;
~*cs-CZ.* cs;
~*^cs cs;
}
server {
listen 80;
server_name lelisoft.com www.lelisoft.com;
root /var/www/lelisoft.com;
index index.html;
location / {
try_files $uri $uri/ /index-$lang.html /index.html;
}
}
And the test usage:
curl -v -H "Accept-Language: cs" http://www.lelisoft.com
* Trying 162.55.54.132:80...
* Connected to www.lelisoft.com (162.55.54.132) port 80 (#0)
> GET / HTTP/1.1
> Host: www.lelisoft.com
> User-Agent: curl/8.0.1
> Accept: */*
> Accept-Language: cs
< Content-Length: 473
< Last-Modified: Sun, 25 Jun 2023 09:03:01 GMT
<
<!DOCTYPE html>
<html lang='eng'>
<head>
I am using nginx-full on Debian.