htaccess的,总是HTTPS:// WWW [英] htaccess, Always https://www
本文介绍了htaccess的,总是HTTPS:// WWW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前使用以下,以确保我的网站一直在使用WWW。我将如何修改这是WWW和HTTPS?
Currently using the following to make sure my website always is using www. How would I modify this to be www and https?
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
想这一点,但最终与www.www.website如果用户没有HTTPS,但也已经有一个WWW
Tried this, but ended up with www.www.website if the user had no https but did already have a www
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
不知道如何将两者结合起来
Not sure how to combine the two
推荐答案
请我们{SERVER_PORT}来查看该请求是否通过定期连接(80)制成,然后重定向到HTTPS URL。
Make us of {SERVER_PORT} to see if the request is made via regular connection (80), then redirect to the https URL.
这应该做到这一点:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
这篇关于htaccess的,总是HTTPS:// WWW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文