【问题标题】:ASP.NET site. Redirect whole domain from http to httpsASP.NET 网站。将整个域从 http 重定向到 https
【发布时间】:2012-09-13 11:41:44
【问题描述】:

就像在标题中一样。如何重定向整个域,例如:http://testdomain.com.au/https://testdomain.com.au/ 我可以在 IIRF 文件中进行吗?如果是的话,这应该是什么样子?如何将 IIRF 文件绑定到站点?

【问题讨论】:

    标签: asp.net redirect iirf


    【解决方案1】:

    您可以通过IIS Rewrite module

    http://www.iis.net/downloads/microsoft/url-rewrite

    http://www.iis-aid.com/articles/how_to_guides/redirect_http_to_https_iis_7

    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
      <match url="(.*)" />
        <conditions>
          <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        </conditions>
       <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
    </rule>
    

    或者您可以通过Global.asax 文件重定向:

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
        if ( !Request.IsSecureConnection)
        {
                string path = string.Format("https{0}", Request.Url.AbsoluteUri.Substring(4)); 
    
                Response.Redirect(path);
        }
    }
    

    http://forums.asp.net/t/1340392.aspx

    【讨论】:

    • 非常感谢。使用 IIRF 文件怎么样? (我问以防万一);)
    猜你喜欢
    • 2013-07-03
    • 1970-01-01
    • 1970-01-01
    • 2015-05-10
    • 1970-01-01
    • 2021-05-11
    • 1970-01-01
    • 2021-12-24
    • 2017-05-07
    相关资源
    最近更新 更多