我的需要是在 web.config 中告诉 IIS 忽略某些 URL 并向客户端发送 HttpRedirect。
为此,我在 web.config 中添加了以下魔法:
<system.webServer>
<httpRedirect enabled="true" httpResponseStatus="Temporary" exactDestination="true">
<add wildcard="*/iac*; " destination="http://someServer.smthg.be/iac$S$Q" />
</httpRedirect>
</system.webServer>
当我尝试向“myserver/iac/john?doe=hello”发出请求时,我只收到 404 not found,而不是我预期的 302。
最佳答案
<rewrite>
<rules>
<clear />
<rule name="test" stopProcessing="true">
<match url="^iac/(.*)" />
<action type="Redirect" url="http://someServer.test.be/iac/{R:1}" appendQueryString="true" redirectType="Temporary" />
</rule>
</rules>
</rewrite>
关于asp.net-web-api - web.config 中使用通配符的 Http 重定向不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33960261/