IIS Rewrite Module and sub applications

╄→гoц情女王★ 提交于 2019-12-03 03:45:43

I think your best option would be to trigger the rewrite rule you already have only when the url doesn't start with one of your sub-applications.

It would be something like:

<rules>
    <rule name="Redirect if SiteName1" stopProcessing="true">
        <match url="^SiteName1/(.*)$" />
        <action type="Redirect" url="{R:1}" />
    </rule>
    <rule name="Rewrite to sub folder">
        <match url="^(SiteName2|SiteName3|SiteName4)/" negate="true" />
        <action type="Rewrite" url="SiteName1/{R:0}" />
    </rule>
</rules>

We keep the redirect when SiteName1/ is requested (we don't need to change this), but the rewrite rule is triggered only when the requested url doesn't start with SiteName2/ or SiteName3/ or SiteName4/ (that's what url="^(SiteName2|SiteName3|SiteName4)/" means and we use negate="true" to triggered the rule only when the pattern is not matched).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!