IIS重写导致重定向问题

问题描述 投票:0回答:1

我在IIS中具有以下规则。

    <rules>
        <rule name="ReverseProxyInboundRule1" stopProcessing="true">
            <match url="(.*)" />
            <action type="Rewrite" url="http://localhost:3000/{R:1}" />
        </rule>
    </rules>

我的Web应用程序内部调用另一个域www.anotherdomain.com/somepage。我的问题是重定向时,它将URL更改为www.mycurrentdomain.com/somepage,这显然会导致404页。可以请一个人帮我写下正确的规则。

注意-重定向是从应用程序代码res.redirect('www.anotherdomain.com/somepage')开始

iis url-rewriting iis-8
1个回答
0
投票
我们需要处理出站规则以应用URL重写规则,而不是使用入站规则。这是一个停止内部调用重定向到外部域(https://www.bing.com)的示例。您可以根据实际需要进行更改。

<system.webServer> <rewrite> <outboundRules> <rule name="MyLocationRule" preCondition="IsRedirection"> <match serverVariable="RESPONSE_Location" pattern="https://www.bing.com/" /> <action type="Rewrite" value="http://{HTTP_HOST}/webform2.aspx" /> </rule> <preConditions> <preCondition name="IsRedirection"> <!--301,302 Url redirection http status code.--> <add input="{RESPONSE_STATUS}" pattern="3\d\d" /> </preCondition> </preConditions> </outboundRules> </rewrite> </system.webServer>

随时让我知道问题是否仍然存在。
© www.soinside.com 2019 - 2024. All rights reserved.