mod_rewrite的WWW到无www和HTTP到HTTPS同步 [英] mod_rewrite www to no-www and http to https simultaneously
本文介绍了mod_rewrite的WWW到无www和HTTP到HTTPS同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前在用code处的mod_rewrite,我发现相同的URL的所有请求重定向加www。
I currently have mod_rewrite in place with code I found to redirect all requests to the same URL without www.
我试图现在要做的就是配置Apache的mod_rewrite做到以下几点,没有任何浪费的动作/额外的重定向。
What I'm trying to do now is configuring Apache mod_rewrite to do the following, without any wasted actions/additional redirects.
http:// to https://
http://www. to https://
我不熟悉它,但在伪code, HTTP(S):(WWW)// domain.com
到 https://domain.com
全权在顶层的URL,不包括子域。
I'm not familiar with it, but in pseudo code, http(s)://(www.)domain.com
to https://domain.com
for solely the URLs at the top level, excluding sub domains.
推荐答案
是的,有这些操作合并成一个单一规则的方式:
Yes, there is a way to combine these operations into a single rule:
RewriteCond %{HTTP_HOST} !=example.com [OR]
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://example.com/$1
这篇关于mod_rewrite的WWW到无www和HTTP到HTTPS同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文