.htaccess重定向到HTTPS(子域除外) [英] .htaccess Redirect to HTTPS except subdomain
本文介绍了.htaccess重定向到HTTPS(子域除外)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将所有非https请求都重定向到https,除了对子域的请求。例如
I would like to redirect all none-https requests to https excepts requests to sub-domains. For example
http://example.com/ => https://example.com/
http://example.com/page => https://example.com/page
但是
http://m.example.com/ REMAINS http://m.example.com/
这是我在.htaccess中拥有的内容,它将重定向所有请求(包括子域):
This is what I have in my .htaccess, which redirects all requests (including sub-domians):
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
我知道我必须在RewriteRule之前添加一个条件,但是我不太确定其语法。
I know that I have to add a condition before the RewriteRule but I am quite not sure about the syntax.
推荐答案
在 RewriteRule之前添加另一个
: RewriteCond
RewriteCond %{HTTP_HOST} !=m.example.com
这篇关于.htaccess重定向到HTTPS(子域除外)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文