将NON-www重定向到www的https [英] Redirect NON-www to www for https

查看:108
本文介绍了将NON-www重定向到www的https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下重定向

RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

如何我将非WWW https重定向到WWW吗?

How can I redirect non WWW https to WWW?

htaccess位于public_html文件夹中

The htaccess is located in the public_html folder

推荐答案

您可以使用以下命令:

RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.example.com%{REQUEST_URI} [L,R=301]

这将重定向

  • http://example.com
  • https://example.com

  • https://www.example.com

这篇关于将NON-www重定向到www的https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆