I see the Nginx HttpRewriteModule documentation has an example to rewrite a www-prefixed domain to a non-www-prefixed domain:
if ($host ~* www\\.(.*)) { set $h
HTTP & HTTPS without if conditions:
server { listen 80; listen 443; server_name website.com; return 301 $scheme://www.website.com$request_uri; } server { listen 80; listen 443 default_server ssl; server_name www.website.com; # Your config goes here # }