简体   繁体   中英

IIS web.config rewrite - Remove specific subfolder from URL

How can I remove a specific subdirectory from my URL?

Examples:

www.mysite.com/web/Login ➡️ www.mysite.com/Login
www.mysite.com/web/Admin/Panel ➡️ www.mysite.com/Admin/Panel
www.mysite.com/web/Orders ➡️ www.mysite.com/Orders

I already tried

        <rewrite>
            <rules>
                <rule name="removeWeb" stopProcessing="true">
                    <match url="^web/(.*)" />
                    <action type="Rewrite" url="{R:1}" />
                </rule>
            </rules>
        </rewrite>

but no success.

For context, this is a .NET Framework site being reached by a .NET Core site with YARP proxy.

Clear the cache and try again, if it still doesn't work, you can try the following rule:

<rewrite>
  <rules>
     <rule name="Remove web" stopProcessing="true">
        <match url=".*(web)(.+)" />
        <action type="Redirect" url=http://www.mytest.com{R:2} appendQueryString="false" />
     </rule>
  </rules>
</rewrite>

Mysite cannot be used in post, so I use test instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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