【问题标题】:web.config rewrite http://www.name.it to https://www.name.comweb.config 将 http://www.name.it 重写为 https://www.name.com
【发布时间】:2018-10-02 10:58:20
【问题描述】:

我搜索了类似的问题,但没有找到具体问题的答案。
我不擅长正则表达式或重写,所以也许我想做的事情无法完成。
我将网站从 http 切换到 https,并使用以下规则将所有 http 请求重定向到相对 https,效果很好。

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

我还拥有通过 dns 重定向到 www.mysite.com 的 www.mysite.it。
使用 actived rewrite 请求被重定向到https://www.mysite.it,我没有 ssl 证书,所以它失败了。

我想重定向
http://www.mysite.it/whatever

https://www.mysite.com/whatever

的请求

我能找到的唯一其他解决方案是为其他域购买一个 ssl,但只是一个重定向,似乎是在浪费钱。

提前感谢您的帮助。

【问题讨论】:

    标签: asp.net url-rewriting web-config


    【解决方案1】:

    你可以硬编码网址...

    <action type="Redirect" url="https://www.name.com/{R:1}" redirectType="Permanent" />
    

    【讨论】:

    • 我想了解如何制定仅拦截 .it 请求的规则,但是...谢谢,您解决了我的问题 :)
    猜你喜欢
    • 2017-12-04
    • 2015-06-18
    • 2014-03-04
    • 2021-08-04
    • 2014-09-20
    • 2012-07-18
    • 2011-06-02
    • 2011-09-15
    • 2016-09-03
    相关资源
    最近更新 更多