简体   繁体   English

IIS的简单URL重写规则

[英]Simple URL rewrite rule for IIS

I need a simple URL rewrite rule for IIS. 我需要一个用于IIS的简单URL重写规则。 If the URL doesn't include "/i" after the domain, I would like to add it. 如果该域后URL不包含"/i" ,我想添加它。

For Example: 例如:

If www.abc.com/sample/test.aspx 如果是www.abc.com/sample/test.aspx

I need the rule to change it to: 我需要规则将其更改为:

www.abc.com/i/sample/test.aspx 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>

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

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