【问题标题】:Http to https redirection for all posibilties to one single url所有可能性的 Http 到 https 重定向到一个单一的 url
【发布时间】:2017-05-10 16:09:22
【问题描述】:

我想将所有可能的 url 组合重定向到单个路径。

例如。

http:/example.com ---> https:/example.com/abc/cde

https:/example.com --> https:/example.com/abc/cde

http:/example.com/abc/cde --> https:/example.com/abc/cde

我可以通过遵循 mod_rewrite 设置来处理 1 和 3 的情况,但不能执行 2 重定向可以帮助一些人。

为了避免链接转换,我在网站示例中使用了一个 /。

重写引擎开启

RewriteCond %{HTTPS} 关闭

RewriteCond %{HTTP:X-Forwarded-Proto} !https

重写规则 ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

【问题讨论】:

    标签: apache http


    【解决方案1】:

    你应该使用[OR]重写标志

     RewriteEngine On
     RewriteCond %{HTTPS} off [OR]
     RewriteCond %{HTTP:X-Forwarded-Proto} !https
     RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-05
      • 2012-03-19
      • 2015-02-13
      • 2014-12-03
      • 2020-11-24
      • 1970-01-01
      • 2011-08-29
      相关资源
      最近更新 更多