V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
miao
V2EX  ›  Apache

.htaccess 如何强制所有首页的 URL 301 跳转到 https://www.example.com ???

  •  
  •   miao · 2016-03-10 18:30:05 +08:00 · 1674 次点击
    这是一个创建于 2968 天前的主题,其中的信息可能已经有所发展或是发生改变。
    假设 域名是 example.com
    那么如何设置 .htaccess ???
    将如下三个首页 URL 跳转到 https://www.example.com
    http://example.com
    https://example.com
    http://www.example.com
    1 条回复    2016-03-14 21:13:43 +08:00
    alect
        1
    alect  
       2016-03-14 21:13:43 +08:00   ❤️ 1
    #跳转所有非 https 请求到 https
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://www.example.com %{REQUEST_URI} [L,R=301,NC]
    #跳转裸域 ssl 到 www ssl
    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule (.*) https://www.example.com .com%{REQUEST_URI} [L,R=301,NC]
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3165 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:47 · PVG 22:47 · LAX 07:47 · JFK 10:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.