简体   繁体   中英

Simple URL rewrite rule for IIS

I need a simple URL rewrite rule for IIS. If the URL doesn't include "/i" after the domain, I would like to add it.

For Example:

If www.abc.com/sample/test.aspx

I need the rule to change it to:

www.abc.com/i/sample/test.aspx

Your rule should be like that:

<rule name="prepend i">
    <match url=".*" />
    <conditions>
        <add input="{REQUEST_URI}" pattern="^/i/" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
   <action type="Redirect" url="/i/{R:0}" />
</rule>

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