【问题标题】:IIS7 redirection best practicesIIS7 重定向最佳实践
【发布时间】:2011-11-09 20:23:48
【问题描述】:

我正在寻找使用 IIS7 和 ASP.net 进行安全站点重定向的“最佳实践”方式。 假设我有两个域名:

  • mydomain.com
  • mydomain.net

每个都有一个 www 子域。

我有一个使用通用名称的 EV 证书:

  • www.mydomain.com

因此,用户可以通过 8 种不同的方式访问网站:

- http://mydomain.com
- http://mydomain.net
- http://www.mydomain.com
- http://www.mydomain.net
- and also using https://

为了不让用户收到证书错误,他/她必须被引导到

 - https://www.mydomain.com

在确保 IIS 只提供安全内容的同时,使这项工作对用户透明的最佳方式是什么?过去我使用 web.config 重定向到这样的子页面:

<system.webServer>

<httpRedirect destination="https://www.mydomain.com/secureSubPage" />

或在通用基本页面中使用此块的通配符证书:

 if (!Request.IsSecureConnection)
    {
        Response.Redirect(Request.Url.ToString().Replace("http:", "https:"), true);
        return;
    }
    if (!Request.Url.ToString().Contains(".com"))
    {
        Response.Redirect(Request.Url.ToString().Replace(".net", ".com"), true);
        return;
    }

【问题讨论】:

  • 这个问题可能更适合ServerFault的“姐妹网站”

标签: asp.net iis ssl


【解决方案1】:

我会使用UrlRewrite,我一直将它用于子域:

Automatically Redirect HTTP requests to HTTPS on IIS 7 using URL Rewrite 2.0

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    • 2016-07-17
    • 2012-09-10
    • 1970-01-01
    • 1970-01-01
    • 2011-11-28
    相关资源
    最近更新 更多