【问题标题】:htaccess rewrite for httpshtaccess 重写 https
【发布时间】:2011-07-23 20:16:11
【问题描述】:

鉴于此规则(从 http 的 URL 中去除 www):

< IfModule mod_rewrite.c >
   RewriteCond %{HTTPS} !=on
   RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
   RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</ IfModule >

如何将重写配置为也适用于 https?

【问题讨论】:

    标签: apache .htaccess


    【解决方案1】:

    简单搜索found this:

    # remove www from host
    RewriteCond %{HTTP_HOST} ^www\.(.+)
    RewriteCond %{HTTPS}s/%1 ^(on(s)|offs)/(.+)
    RewriteRule ^ http%2://%3%{REQUEST_URI} [L,R=301]
    

    注意:如果没有应用 [L]ast 规则,[L] 指令在您的情况下可能是多余的...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多