简体   繁体   English

IIS URL重写规则以隐藏子文件夹

[英]IIS url rewrite rules to hide subfolders

I have 2 .net API projects, servce1 and service2. 我有2个.net API项目servce1和service2。 I would like to put them both under the same domain (site). 我想将它们都放在同一个域(站点)下。 I can ensure the APIs routing not overlapping. 我可以确保API路由不会重叠。 I deployed the projects as: 我将项目部署为:

What I want to achieve is that I can use http://mydomain/api/ONE or http://mydomain/api/TWO to access both service1 and service2 APIs without the subfolders in the URL. 我想要实现的是,我可以使用http:// mydomain / api / ONEhttp:// mydomain / api / TWO来访问service1和service2 API,而无需URL中的子文件夹。

I tried using URL rewrite module I got it works for one, but I can not get the second one work, with the same settings. 我尝试使用URL重写模块,但我只能使用其中一个设置,但是我无法使用相同的设置来获得第二个作品。 See the setting file below. 请参阅下面的设置文件。

I tried moving the rules orders. 我尝试移动规则命令。 no luck. 没运气。

<rewrite>
        <rules>
            <clear />
            <rule name="first" stopProcessing="false">
                <match url="(.*)ONE(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                    <add input="{REQUEST_URL}" pattern="(.*)/api/ONE(.*)" />
                </conditions>
                <action type="Rewrite" url="/Servuce1/api/ONE{R:2}" logRewrittenUrl="true" />
            </rule>
            <rule name="seconds" stopProcessing="false">
                <match url="(.*)TWO(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                    <add input="{REQUEST_URI}" pattern="(.*)/api/TWO(.*)" />
                </conditions>
                <action type="Rewrite" url="/service2/api/TWO{R:2}" logRewrittenUrl="true" />
            </rule>
        </rules>
    </rewrite>

What is wrong with my settings? 我的设置有什么问题?

What are the alternatives? 有哪些选择?

应该将stopProcessing设置为“ true”,以便在匹配第一个规则时不应用第二个规则吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM