我如何重定向https://到https://www上.haccess文件


How do I redirect https:// to https://www on .htacess file?

我正在修改. haccess。我尝试用下面的代码将https://mydomain.com更改为https://www.mydomain.com。而失败了。

# REDIRECT HTTPS:// TO HTTPS://WWW.
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^my___domain'.com$ [NC]
RewriteRule ^(.*)$ http://www.my___domain.com/$1 [R=301,L]

我做错了什么?


作为提示:

如果这有帮助,我在开始时使用了这些代码,将IP和原始的3_$ (_">http://my3_$.com)重定向到_">http://www.3__$.com。

# REDIRECT IP TO WWW.
RewriteCond %{HTTP_HOST} ^xxx'.xxx'.xxx'.xxx
RewriteRule (.*) http://www.my___domain.com/$1 [R=301,L]
# REDIRECT HTTP:// TO HTTP://WWW.
RewriteCond %{HTTP_HOST} ^my___domain'.com$ [NC]
RewriteRule ^(.*)$ http://www.my___domain.com/$1 [R=301,L]

我正在尝试重定向https://,因为在成功修改上述两个页面后,我无法登录,因为那些是https://页面。

谢谢

//www.___.com/$1代替http://www.___.com/$1。它将使用原始请求中使用的http或https。目前,您正在强制http,这似乎与您想要的相反。

我使用这个重写从http重定向到https:

RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

我想在你的情况下,加上这样的东西就可以了:

RewriteCond %{HTTP_HOST} ^domain'.com$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

嗯?