【问题标题】:Redirect http to https and www to non www url iis Url Rewrite [duplicate]将http重定向到https,将www重定向到非www url iis Url Rewrite [重复]
【发布时间】:2018-07-25 00:10:30
【问题描述】:
<rule name="UreRedirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
    <add input="{HTTPS}" pattern="^OFF$" />
    <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="https://example.com/{R:1}" redirectType="SeeOther" />

我正在使用上面的 web.config 代码

我已经使用 IIS 添加了所有可能的绑定

SSL 是为 example.com 配置的,但不是为 www.example.com 配置的

我尝试了这些链接,但这些都无关紧要

iis url redirect http to non www https

How to redirect http to https and www to non-www via web.config?

【问题讨论】:

    标签: c# asp.net url-rewriting iis-7


    【解决方案1】:

    你可以用这个:

    <rewrite>
      <rules>
        <rule name="redirect" enabled="true">
          <match url="(.*)" />
          <action type="Redirect" url="https://piposx.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
    

    【讨论】:

    • 在我们点击进入不安全网站后,它看起来重定向有效。可能我将不得不添加 www.piposx.com 以使用我的主机保护网站?
    • 我已经写了 www.piposx.com 及其工作。您可能需要清除浏览器缓存。
    • 你试过piposx.com吗?
    • 好的,我明白了。我认为问题在于您已经为piposx.com (https://www.piposx.com) 配置了 SSL 证书,如果您打开证书详细信息,它会说它已颁发给 crititac.com。从您的配置中删除它,一切都应该正常工作。
    • 你能解释一下吗?
    猜你喜欢
    • 2013-06-11
    • 2019-12-13
    • 1970-01-01
    • 2016-10-14
    • 2015-08-03
    • 2017-11-24
    • 2017-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多