多个URL重写规则IIS Express

时间:2019-08-15 16:18:58

标签: iis url-rewriting

我想实现重写所有请求,例如something.mypage.hu/some或otherthing.nypage.hu 到一个IP地址。

但是我想将nuget.mypage.hu重写为另一个IP地址。

我应该如何创建规则?

如果我仅使用第一个规则

          ```<rule name="ReverseProxyInboundRule1" stopProcessing="true">
                <match url="^(.*).somepage.hu(.*)" />
                <action type="Rewrite" url="http://SOMEIP:5000/{R:1}/{R:2}" />```

工作正常。我只是无法为指向不同IP地址的nuget.mypage.hu使用另一个规则。

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="^(.*).somepage.hu(.*)" />
                    <action type="Rewrite" url="http://SOMEIP:5000/{R:1}/{R:2}" />
                    <conditions>
                        <add input="{REQUEST_URI}" pattern="^nuget.somepage.hu(.*)" negate="true" />
                    </conditions>
                </rule>
                <rule name="ReverseProxyInboundRule2" stopProcessing="true">
                    <match url="^(.*)nuget.somepage.hu(.*)" />
                    <action type="Rewrite" url="http://localhost/nuget/{R:1}" />
                    <conditions>
                        <add input="{REQUEST_URI}" pattern="^(.*)nuget.somepage.hu(.*)" />
                    </conditions>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

呼叫url只是不重写任何呼叫。

0 个答案:

没有答案