nginx automatically jumps to www

LIYITONGXUEAugust 23, 2022
About 1 min...

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/108941584open in new window

Last update: 8/23/2022, 7:58:42 AM
Comments
Powered by Waline v2.6.2