Stack Overflow上有许多类似的解决方案,例如htaccess http to https with www. Without redirecting sub domain。
然而,我需要的是:
我正在运行WordPress Multisite网站,并且没有通配符SSL。
我现在正在使用以下内容:
非WWW
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} www.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
非WWW和非HTTPS子域
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !=subdomain1.main.com
RewriteCond %{HTTP_HOST} !=subdomain2.main.com
RewriteCond %{HTTP_HOST} !=subdomain3.main.com
RewriteCond %{HTTP_HOST} !=subdomain4.main.com
SSL
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
答案 0 :(得分:1)
这是你想要的吗?
RewriteEngine On
RewriteBase /
# www is redirected to base domain
RewriteCond %{HTTP_HOST} ^www\.([^\.]+\.[^\.]+)$
RewriteRule ^(.*)$ https://%1/$1 [L,R=301]
# base domain should use HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^[^\.]+\.[^\.]+$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]
# other domain should use HTTP
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^[^\.]+\.[^\.]+$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,R=301]