ubuntu-19.10

Nginx: How to match ONLY the main domain with server_name

こ雲淡風輕ζ 提交于 2021-02-10 16:55:46
问题 My goal is to redirect example.com into www.example.com without redirecting any subdomain to www . This is what I have: server { listen 443; server_name example.com; return 301 https://www.$server_name$request_uri; } With this configuration every subdomain (ex: foo.example.com ) gets redirected into www.example.com , not just the main one without subdomain ( example.com ), as I would like. I tried cleaning cache (and also doing it from other browsers) with same results. Edit: The proof that