【问题标题】:htaccess quite domains not www to https://www but not subdomains to wwwhtaccess 相当域不是 www 到 https://www 但不是子域到 www
【发布时间】:2017-07-31 15:15:46
【问题描述】:

我找到了很多示例,但所有示例都是针对特定域的,并且我的服务器有许多主域和子域。

我希望将所有主域重写为 https://www,但子域仅重写为 https://:

main-domain.xxx       -> https://www.main-domain.xxx
sub.main-domain.xxx   -> https://sub.main-domain.xxx

我现在正在使用这个规则来获取 https://

RewriteCond %{REQUEST_SCHEME} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

【问题讨论】:

    标签: .htaccess mod-rewrite subdomain no-www


    【解决方案1】:

    我发现这是一个问题而不是答案,但对我来说很好:

    RewriteCond %{REQUEST_SCHEME} !https
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-02
      • 2016-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-16
      • 2014-10-26
      相关资源
      最近更新 更多