我试图模拟托pipe与IIS7的单个网站上的多个域。
我设置了一个文件夹结构,它具有一个web_root文件夹,其中包含一个简单的index.html,一个web.config和一个持有asp.net Web应用程序的文件夹(连接)。 我试图添加一个URL重写规则,将请求到主机localhost.nerdfurio.us并将其指向连接文件夹(我也添加localhost.nerdfurio.us到我的主机文件)。
web_root中的web.config如下所示
<configuration> <system.webServer> <modules runAllManagedModulesForAllRequests="true"> </modules> <rewrite> <rules> <rule name="nerdfurious" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^localhost.nerdfurio.us$" /> <add input="{PATH_INFO}" pattern="^/connect/" /> </conditions> <action type="Rewrite" url="connect/{R:0}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
当我在浏览器中input“localhost.nerdfurio.us”时,我得到了index.html文件的内容。 如果我在我的浏览器中键入localhost.nerdfurio.us/connect,我得到一个404错误列表“ http://localhost.nerdfurio.us:80/connect/connect/ ”作为请求的URL。 我错过了什么?
问题是, {PATH_INFO}规则需要在标签中具有negate="true"属性。 这意味着当模式不匹配。 因为当我访问根目录时,“/ connect /”不在url中,所以所有的条件都不符合重写操作。