Matching part of url and redirect

47 Views Asked by At

I have a regular expression in my web.config file that I'm using to redirect users to some other domain:

<redirect url="/(.*/)?((da-DK)|(es-ES))/?$" to="http://www.example.com" />

This successfully matches following url:

http://www.example.com/ik/da-DK/

But not the below one:

http://www.example.com/da-DK/

Why is that? I'm certain that this regex is good because I've tested it against lots of example urls. Is this a bug in parser or something like that?

I'm using urlrewriter.net which is no longer maintained, but maybe any of you had such problems in the past?

1

There are 1 best solutions below

0
Vlatko Vlahek On

Regex itself seems ok, so considering that urlrewriter.net is not actively maintained, I would suggest that you try to switch to IIS Url Rewrite:

http://www.iis.net/downloads/microsoft/url-rewrite