首页 文章

Http将https重定向所有posibilties重定向到一个网址

提问于
浏览
0

我想将每个可能的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重定向可以帮助一些 .

我有一个/在网站示例中逃避只是为了避免链接转换 .

RewriteEngine On

RewriteCond%关闭

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

RewriteRule ^( . *)$ https://% [R = 301,L]

1 回答

  • 1

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

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

相关问题