IIS7 URL重写模块:强制为root

我们在端口80上的IIS7中有两个站点。一个是我们的实际网站(MAIN),另一个是维护站点(MAINTENANCE),当我们部署新版本的MAIN时,我们启动(并停止另一个站点)。

当我们把维护生活,如果你浏览到我们的子文件夹之一(即http:// maintenance / product1 ),你会得到一个404。我想使用URL重写模块redirect到网站的根( http: //维护/ )。

我可以以基本的方式得到这个工作,但图像和CSS不起作用。 在其他尝试中,我已经结束了不断的redirect。

这可能吗?

对于通过Google来到这里的任何人,我都设法使其符合以下规则:

<rewrite> <rules> <clear /> <rule name="Force HTTP" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTPS}" pattern="on" /> </conditions> <action type="Redirect" url="/{R:1}" redirectType="Temporary" /> </rule> <rule name="Allow Local Resources" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAny" trackAllCaptures="false"> <add input="{REQUEST_FILENAME}" pattern="SiteMaintenance.png" /> <add input="{REQUEST_FILENAME}" pattern="Stylesheet.css" /> </conditions> <action type="None" /> </rule> <rule name="Check Is Root" stopProcessing="true"> <match url="^.+$" negate="false" /> <conditions logicalGrouping="MatchAny" trackAllCaptures="false" /> <action type="Redirect" url="/" appendQueryString="false" redirectType="Temporary" /> </rule> </rules> </rewrite> 

不知道这是否是最好的方法,但它对我有效。

🙂