将http重定向到https(不包括子域) [英] Redirect http to https (excluding sub domain)

查看:127
本文介绍了将http重定向到https(不包括子域)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上安装了ssl,而我的ssl许可证仅适用于基域(不在子域)

I have installed ssl on my site and my ssl license only work on base domain (not on sub domains)

我在.htaccess文件中使用以下代码进行重定向所有http呼叫https。但问题是它还将子域重定向到我的基础doamin。
例如www.sub.mydomain.com redirecs to https://www.mydomain.com : (

i use following code in .htaccess file to redirect all http call to https. But the problem is it also redirect subdomain to my base doamin. for example www.sub.mydomain.com redirecs to https://www.mydomain.com :(

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]

但我想要的是,只将基域调用重定向到https不干扰子域:(

but what i want, redirect only base domain call to https not interfere sub domains :(

推荐答案

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} www.mydomain.com
RewriteRule (.*)  https://www.mydomain.com/$1 [R=301,L]

我认为规则可能只是

RewriteRule (.*)  https://www.mydomain.com$1 [R=301,L]

离开超出额外斜线,应该包括在规则匹配中。但我总是忘记这是否有效。

leaving out the extra slash, which should be included in the rule match. But I always forget whether that works or not.

这篇关于将http重定向到https(不包括子域)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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