简体   繁体   English

htaccess 重定向到 http 而不是 https

[英]htaccess redirects to http instead of https

I've set a redirect rule in htaccess - but instead of redirecting the url to the right scheme (https) it first redirect to http.我在 htaccess 中设置了重定向规则 - 但不是将 url 重定向到正确的方案 (https),​​而是首先重定向到 http。 for example:例如:

RewriteRule ^prefixurl/(aaa|bbb|ccc)/suffixurl$ prefixurl/ddd/suffixurl [R=301,QSA,L]

What happens is I get from :发生的事情是我从:

https://www.example.com/prefixurl/bbb/suffixurl https://www.example.com/prefixurl/bbb/suffixurl

--> (redirects to) -->(重定向到)

http://www.example.com/prefixurl/ddd/suffixurl http://www.example.com/prefixurl/ddd/suffixurl

--> (2nd redirect to) -->(第二次重定向到)

https://www.example.com/prefixurl/ddd/suffixurl https://www.example.com/prefixurl/ddd/suffixurl

(there is nginx server in front of Apache with directive to move all non https back to https...) (Apache 前面有 nginx 服务器,指令将所有非 https 移回 https...)

Why the redirect to http takes place ?为什么会重定向到 http? any way to fix it ?有什么办法解决吗?

您可以使用此单一规则来获取重定向并在重定向 URL 中获取https://

RewriteRule ^prefixurl/(aaa|bbb|ccc)/suffixurl$ https://%{HTTP_HOST}/prefixurl/ddd/suffixurl [R=301,NC,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM