【问题标题】:Redirect https://www.subdomain.domain.com/ to https://subdomain.domain.com将 https://www.subdomain.domain.com/ 重定向到 https://subdomain.domain.com
【发布时间】:2012-11-16 01:00:10
【问题描述】:

我想将https://www.subdomain.domain.com/ 重定向到https://subdomain.domain.com,我们已将其包含在 htaccess 文件中,但它不起作用:

RewriteCond %{HTTPS_HOST} ^www\.([^.]+)\.domian\.com$
RewriteRule ^(.*)$ https:// %1.domian.com/$1 [L,R]

【问题讨论】:

  • 您有 www.subdomain.domain.com 或 subdomain.domain.com 的证书?

标签: apache .htaccess mod-rewrite


【解决方案1】:

这会将所有 https 和 www 重定向到非 www 等效项:

RewriteCond %{HTTPS}=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R,L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-11
    • 2021-12-28
    • 1970-01-01
    • 2020-09-11
    • 2017-04-02
    • 2016-09-24
    • 1970-01-01
    • 2016-03-10
    相关资源
    最近更新 更多