url rewrite in web.config

狂风中的少年 提交于 2019-12-25 07:48:38

问题


I've been reading articles regarding Url Rewrite in web.config but I don't understand why my redirection doesn't work. Below is my sample url:

localhost/MySite/1542

and here's the pattern I used for matching the url:

<rule name="testRedirect" stopProcessing="true">
   <match url="^/MySite/([0-9]+)" />
   <action type="Redirect" url="/MySite/default.html" />
</rule>

can someone enlighten me what's wrong with my code?


回答1:


try removing the leading / in matching url ^MySite/([0-9]+)

<rule name="testRedirect" stopProcessing="true">
   <match url="^MySite/([0-9]+)" />
   <action type="Redirect" url="/MySite/default.html" />
</rule>


来源:https://stackoverflow.com/questions/28445529/url-rewrite-in-web-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!