如何重定向到https://example.com/ https://www.example.com/ [英] How to Redirect https://example.com/ to https://www.example.com/
本文介绍了如何重定向到https://example.com/ https://www.example.com/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这个code我国的.htaccess
文件,如下图所示。
I have this code in my .htaccess
file as shown below.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
这被添加到HTTP重定向到https所以整个网站现在是HTTPS版本。
This was added to redirect http to https so the entire site is now in https version.
现在我想从非www到www重定向。当我键入example.com我应该被重定向到 https://www.example.com/
Now I want to redirect from non-www to www. When I type example.com I should be redirected to https://www.example.com/
我如何做到这一点与的.htaccess
文件?
How do I do that with an .htaccess
file?
推荐答案
非SSL重定向:结果
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com$1 [R=permanent,L]
SSL重定向:结果
SSL redirection:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ https://www.domain.com$1 [R=permanent,L]
这篇关于如何重定向到https://example.com/ https://www.example.com/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文