我有世界上最简单的正则表达式:*
我将它放在 IIS 的一个网站中,因为我希望其中一个网站成为代理,而其他网站在本地提供服务。所以,web.config 是:
<system.webServer>
<rewrite>
<rules>
<rule name="AllRewrite" stopProcessing="true">
<match url="*" />
<action type="Rewrite" url="http://tom-pc/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
但是,这会引发此错误:
The expression "" contains a repeat expression (one of '', '?', '+', '{' in most contexts) that is not preceded by an expression.
有什么想法吗?
最佳答案
错误说明了一切。您的正则表达式无效。 * 是重复字符(零次或多次)。您应该指明允许哪个字符重复零次或多次。你可能想要任何字符,所以你的正则表达式应该是:.*
<match url=".*" />
要回答有关代理的其他问题,不可能通过重写到另一个主机名来代理。您只能重写同一服务器上的其他 URI。要使用 IIS 代理,您必须安装 ARR(应用程序请求路由)模块。
关于iis - 简单 IIS 重定向表达式 ("*") 引发错误 : The expression "*" contains a repeat expression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7912831/