url从http重定向到https - 域和子域不同

时间:2015-12-14 21:12:56

标签: .htaccess https ssl-certificate subdomain

我有以下代码,它们可以同时用于域名和子域名重定向到https。

但实际上它会将所有内容重定向到主域名。

实施例

protected void gvSOPDetails_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "ViewAttachment")
        {
            hfSelectedSOP.Value = (string)e.CommandArgument;
            mpeAttachments.TargetControlID = "btnShowModelPopup";
            lvSupportingAttachments.DataBind();
            mpeAttachments.Show();

  }
    }

这是我的代码......

Main domain - example.com and www.example.com
Sub Domain - aa.example.com and www.aa.example.com

上述代码的作用是,example.com和www.example.com工作正常。但是,当我来到aa.example.com或www.aa.example.com时,它会重定向到example.com

我做错了什么?

1 个答案:

答案 0 :(得分:1)

你应该可以尝试这样的东西,它将获得主域和子域。

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(.+)?example\.com
RewriteRule ^ https://%1example.com%{REQUEST_URI} [R=301,L]
相关问题