【发布时间】:2014-07-11 07:22:36
【问题描述】:
我正在使用 IIS7 中的 URL 重写功能。我在 80 端口上建立了一个网站,并设置了一些 URL 重写规则。
第一条规则需要指向 8090 端口上的 Web 应用程序,另一条规则需要指向 8091 端口上的 Web 应用程序。
规则需要这样配置:
-
http://localhost/重写为http://localhost:8090 -
http://localhost/test重写为http://localhost:8091。
这是我使用的规则:
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Site2" enabled="true" stopProcessing="true">
<match url="^.*/test/.*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="http://{HTTP_HOST}:8091/{R:0}" />
</rule>
<rule name="Site1" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="http://{HTTP_HOST}:8090/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
我会提到“Site1”规则正在运行。如果我转到 http://localhost/,我会看到托管在端口 8090 上的 Web 应用程序。如果我转到 http://localhost/test,我会看到 404 错误。
【问题讨论】:
-
你有没有想过这个问题?我有exact same problem。
-
您可以在下面找到我的解决方案。希望这会有所帮助。
标签: .net iis url-rewriting rewrite