简体   繁体   中英

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. 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

--> (redirects to)

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

--> (2nd redirect to)

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...)

Why the redirect to http takes place ? any way to fix it ?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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