【问题标题】:add https for subdomains using .htaccess使用 .htaccess 为子域添加 https
【发布时间】:2015-04-29 20:14:47
【问题描述】:

我有两个子域,例如 schools.mydomain.co.ukadmin.mydomain.co.uk,我需要为这两个域的所有请求 url 添加 https://,我已经将我的 .htaccess 更改如下。这两个子域指向同一个根文件夹。 但出现错误“此网页有重定向循环”

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^admin\.mydomain\.co\.uk [NC]
RewriteRule (.*) https://admin.mydomain.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^schools\.mydomain\.co\.uk [NC]
RewriteRule (.*) https://schools.mydomain.co.uk/$1 [R=301,L]

【问题讨论】:

    标签: .htaccess mod-rewrite url-rewriting subdomain


    【解决方案1】:

    您没有使用HTTPS检查它们是否已被访问:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTPS} ^off
    RewriteCond %{HTTP_HOST} ^(admin|schools)\.mydomain\.co\.uk [NC]
    RewriteRule (.*) https://%1.mydomain.co.uk/$1 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2010-11-06
      • 2014-01-25
      • 2012-06-05
      • 2014-01-20
      • 2016-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-11
      相关资源
      最近更新 更多