nginx automatically jumps to www
August 23, 2022
Edit the conf/nginx.conf file in the ngnix installation directory
server {
  listen 80;
  server_name www.xxx.com xxx.com;
  if ($host != 'www.xxx.com') {
  rewrite ^/(.*)$ http://www.xxx.com/$1 permanent;
  }
}
server {
  listen 443;
  server_name www.xxx.com xxx.com;
  if ($host != 'www.xxx.com') {
  rewrite ^/(.*)$ https://www.xxx.com/$1 permanent;
  }
}
Tips
xxx.com is your website address
Reference:https://blog.csdn.net/gdali/article/details/108941584