简体   繁体   English

将主域和support.example.com重定向到https,但所有其他子域除外

[英]redirect primary domain and support.example.com to https except all other subdomain

I am creating wildcard subdomain for usernames and also i created SubDomain for support centre that support.example.com 我正在为用户名创建通配符子域,也为支持中心support.example.com创建了SubDomain。

I have already installed SSL certificate on Primary Domain (example.com) and (support.example.com) and used following .htaccess for automatically redirection to https url. 我已经在主域(example.com)和(support.example.com)上安装了SSL证书,并在.htaccess之后用于自动重定向到https url。

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

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

But all other wildcard subdomains for usernames created dynamically but they don't have SSL certificate. 但是用户名的所有其他通配符子域是动态创建的,但没有SSL证书。

I want example.com and support.example.com to redirected to https and all other sub domains on http only. 我想将example.com和support.example.com重定向到仅HTTP上的https和所有其他子域。

Can anyone tell me what changes i make in my htaccess :) 谁能告诉我我对htaccess进行的更改:)

What is the first RewriteRule doing? 第一个RewriteRule在做什么?

However, I suggest you may put an additional RewriteCond into your second RewriteRule to only redirect to https when on example.com and support.example.com: 但是,我建议您可以在第二个RewriteRule放置一个额外的RewriteCond以便仅在example.com和support.example.com上重定向到https:

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(support\.)?example\.com$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM