【问题标题】:Trying to redirect subdomains to non http but it's not working尝试将子域重定向到非 http 但它不起作用
【发布时间】:2016-11-01 09:55:19
【问题描述】:

我在 wordpress 多站点上使用它来将我的主域重定向到 https,并将所有子域重定向到非 https,但是,它仅适用于主域:

# for main domain
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://domain.com%{REQUEST_URI} [R=301,L,NE]

# for sub domain
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain\.domain\.com$ [NC]
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ http://subdomain.domain.com%{REQUEST_URI} [R=301,L,NE]

我尝试了几种不同的方法,但似乎无法让子域重定向到 http。 :/ 有什么想法吗?

【问题讨论】:

    标签: wordpress .htaccess redirect subdomain multisite


    【解决方案1】:

    尝试:

    # for main domain
    RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^www\. [NC]
    RewriteRule ^ https://domain.com%{REQUEST_URI} [R=301,L,NE]
    
    # for sub domain
    RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
    RewriteCond %{HTTPS} on
    RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
    

    【讨论】:

    • 试过了,但得到了相同的结果。当转到https://sub.domain.com 时,它只会给我一个隐私错误,而不是重定向。 :(
    • 这是https的工作原理。如果您尝试重定向到 http,则会收到一条安全消息通知用户。
    猜你喜欢
    • 2015-05-19
    • 2018-10-25
    • 2018-01-27
    • 2015-04-01
    • 1970-01-01
    • 2018-10-24
    • 1970-01-01
    • 2016-01-30
    • 1970-01-01
    相关资源
    最近更新 更多