【问题标题】:Rewrite URL iis 7 - https://www.somewhere.com -> https://somewhere.com重写 URL iis 7 - https://www.somewhere.com -> https://somewhere.com
【发布时间】:2012-02-28 19:54:42
【问题描述】:

我正在尝试从 WWW -> 根目录重定向我的网站。

http://www.example.com -> http://example.com https://www.example.com -> https://example.com

我使用了以下重写规则:

<rule name="CanonicalHostNameHttp" stopProcessing="true">
<match url="(.*)" />  
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="http://example.com/{R:1}" />
</rule>

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

这很好用:

这失败了:

  • 我输入https://www.example.com
  • 它永远不会重定向到https://example.com
  • 因此它给了我一个证书错误(因为我的证书是 example.com 而不是 www.example.com)

我错过了什么???

【问题讨论】:

    标签: ssl iis-7 url-rewriting ssl-certificate url-rewrite-module


    【解决方案1】:

    如何为 www.example.com 购买便宜的证书,如此处所述...invalid security certificate and domain names ...然后设置规则重定向https://www.example.com -> https://example.com?

    我现在也有类似的问题。问题是我无法安装第二个证书,因为 Amazon EC2 将每个实例限制为一个公共 IP 地址,并且一个 IP 地址只能绑定到一个证书。我能想到的唯一选择是将我的非规范化域的 DNS 更改为指向另一台服务器,在那里安装第二个证书,然后让它重定向到我的 EC2 实例。

    【讨论】:

    • 我也在亚马逊上,我想我可以尝试重定向...虽然是另一台服务器来管理和支付:-(
    • 我有一个通配符证书,但我仍然做不到......直到现在!我刚刚意识到我在绑定中指定了主机名。我已经清除了所有主机名,现在它正在工作。谢谢您的帮助! :) PS。 GeoTrust 有相当便宜的通配符证书。
    猜你喜欢
    • 2012-07-23
    • 1970-01-01
    • 2016-03-20
    • 2018-02-02
    • 2015-07-27
    • 2016-06-30
    • 1970-01-01
    • 2020-11-28
    • 2013-07-01
    相关资源
    最近更新 更多