V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
watch
V2EX  ›  Linux

nginx 301 配置问题

  •  
  •   watch · 2020-01-09 15:16:21 +08:00 · 2517 次点击
    这是一个创建于 1561 天前的主题,其中的信息可能已经有所发展或是发生改变。
    域名:a.com

    需求:将 a.comwww.a.com ( http 及 https 协议)全部重定向到 https://www.a.com

    这样写配置可以吗:

    server {
    listen 80;
    listen 443 ssl http2;
    server_name www.a.com a.com;
    if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
    if ($host != www.a.com) { return 301 $scheme://www.a.com$request_uri; }
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5696 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 01:55 · PVG 09:55 · LAX 18:55 · JFK 21:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.