在Web.config中定义重定向后,重定向错误太多

时间:2017-11-24 14:12:48

标签: c# asp.net asp.net-mvc redirect

我有一个ASP.NET MVC(5)应用程序,需要重定向诸如

之类的URL

<domain>/london<domain>/locations/london

我已在system.Webserver

中的Web.config中定义了重定向
<rule name="london">
     <match url="london" />
     <action type="Redirect" url="locations/london" />
</rule>

当我在本地运行网站并浏览到localhost:1111/london时,我收到以下错误

  

localhost重定向了你太多次了。 ERR_TOO_MANY_REDIRECTS

我做错了什么?

我花了一些时间在线查看但却找不到答案......

1 个答案:

答案 0 :(得分:4)

您的规则基本上是说网址是否包含London,然后重定向到locations/London。但locations/London也包含单词London,因此它会再次重定向。

尝试将规则设置为

^london

(从伦敦开始)