关于 nginx 域名跳转的问题

2019-08-17 21:38:08 +08:00
 jsjcjsjc

情况是这样的,无论输入下列哪种情况,都希望跳转到 bcd456.com
应该怎么写啊
http://www.abc123.com
http://123213.abc123.com
http://abc123.com
http://www.abc123.com/3232d
http://123213.abc123.com/3232d
http://abc123.com/3232d
https://www.abc123.com
https://123213.abc123.com
https://abc123.com
https://www.abc123.com/3232d
https://123213.abc123.com/3232d
https://abc123.com/3232d

原来是这样配置的,但是这两个不行
https://www.abc123.com
https://123213.abc123.com
https://www.abc123.com/3232d
https://123213.abc123.com/3232d

server
    {
        listen 80;
        server_name abc123.com www.abc123.com *.abc123.com;
        location / {
              rewrite ^/(.*) https://abc123.com/$1 permanent;
        }
    }

server {
  server_name abc123.com;
  listen 443;

  ssl on;
  ssl_certificate /etc/letsencrypt/m/fullchain.pem;
  ssl_certificate_key /etc/letsencryp/privkey.pem;

  return 301  http://bcd456.com$request_uri;
}server
    {
        listen 80;
        server_name abc123.com www.abc123.com *.abc123.com;
        location / {
              rewrite ^/(.*) https://abc123.com/$1 permanent;
        }
    }

server {
  server_name abc123.com;
  listen 443;

  ssl on;
  ssl_certificate /etc/letsencrypt/m/fullchain.pem;
  ssl_certificate_key /etc/letsencryp/privkey.pem;

  return 301  http://bcd456.com$request_uri;
}

后来申请了泛域名配置改成如下,发现只有这 4 个可以跳转
https://www.abc123.com
https://123213.abc123.com
https://www.abc123.com/3232d
https://123213.abc123.com/3232d

server
    {
        listen 80;
        server_name abc123.com www.abc123.com *.abc123.com;
        location / {
              rewrite ^/(.*) https://abc123.com/$1 permanent;
        }
    }


server {
  server_name abc123.com www.abc123.com *.abc123.com;
  listen 443;

  ssl on;
  ssl_certificate /etc/letsencrypt/m/fullchain.pem;
  ssl_certificate_key /etc/letsencryp/privkey.pem;

  return 301  http://bcd456.com$request_uri;
}
2882 次点击
所在节点    NGINX
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/592768

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX