简体   繁体   中英

Too many redirects error after defining a redirect in Web.config

I have an ASP.NET MVC (5) application and need to redirect urls such as

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

I've defined a redirect in Web.config in system.Webserver

<rule name="london">
     <match url="london" />
     <action type="Redirect" url="locations/london" />
</rule>

When I run the site locally and browse to localhost:1111/london I get the following error

localhost redirected you too many times. ERR_TOO_MANY_REDIRECTS

What am I doing wrong?

I've spent some time looking online but can't find the answer...

your rule is basically saying if the URL contains London then redirect to locations/London . But locations/London contains the word London too so it will redirect again.

Try setting the rule to be

^london

(start with london)

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