nginx自动跳转到www

LIYITONGXUE2022年8月23日
大约 1 分钟...

编辑ngnix的安装目录下的conf/nginx.conf文件

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;
  }
}

提示

其中xxx.com为您的网站地址

参考链接:https://blog.csdn.net/gdali/article/details/108941584open in new window

上次编辑于: 2022/8/23 07:58:42
评论
Powered by Waline v2.6.2