【问题标题】:IIS7 Rewrite Rule to redirect http://example.com to https://www.example.comIIS7 重写规则将 http://example.com 重定向到 https://www.example.com
【发布时间】:2012-04-18 13:25:25
【问题描述】:

我希望以下内容重定向到https://www.domain.com

我使用 IIS 中的默认规则进行规范域重定向,它使用这种模式:

^www\.domain\.com$

这适用于第一个。 www 域不会重定向。我尝试删除 ^ 但这不起作用。我该如何解决这个问题?

【问题讨论】:

  • 如果有一些域明确保留用于示例......哦,等等。

标签: asp.net iis url-rewriting


【解决方案1】:

假设您在 IIS7 上有 URL-Rewrite 模块?

HTTP 到 HTTPS 重定向的典型示例:

<rule name="Redirect to HTTPS" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{HTTPS}" pattern="^OFF$" />
  </conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>

你可以试试吗?

【讨论】:

  • 单独使用,仅适用于 www。然后我添加了默认的规范重定向,它适用于两者。谢谢
猜你喜欢
  • 2014-03-04
  • 2020-09-24
  • 1970-01-01
  • 2015-09-25
  • 1970-01-01
  • 2017-12-21
  • 2020-12-21
  • 1970-01-01
  • 2011-07-06
相关资源
最近更新 更多