繁体   English   中英

IIS URL重写(重定向)

[英]IIS URL Rewrite (redirect)

我想用我的URL中的“ home”替换“ index”,例如:

www.mywebsite.com/index应该重定向到www.mywebsite.com/home

www.mywebsite.com/index/contactwww.mywebsite.com/home/contact等。

我尝试应用此规则

<rule name="Replace index" stopProcessing="true">
    <match url="(.*)(/index)(.*)" />
    <action type="Redirect" url="localhost:6782/home{R:3}" />
</rule>

该规则应选择(any-string)(/index)(any-other-string)并将其替换为localhost:6782/home{any-other-string}但它不会执行任何操作。

IIS正则表达式测试模式

这是我的问题的答案:

 <rules>
    <rule name="Redirect to home" stopProcessing="false">
      <match url="^index(.*)" />
      <action type="Redirect" url="home{R:1}" redirectType="Permanent" />
    </rule>
 </rules>

提示 :尝试不同的规则时,请确保清除浏览器的缓存(或使用隐身模式)

暂无
暂无

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

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