Multiple matches

Topics: User Forum
Sep 21, 2009 at 9:33 AM

Hi,

I've been through the documentation a few times and can't seem to find any answer to my quesstion so hopefully someone here can help?

If I have these two redirect rules:

RedirectRule ^/test http://www.domain.com/test.aspx [I,R=301]
RedirectRule ^/testing http://www.domain.com/testing.aspx [I,R=301]

Then when I type www.domain.com/testing, it redirects to /test.aspx because it is matching the first rule.  Is there anyway to make the url-pattern be an exact match?

Thanks for your help!

Mike

 

Coordinator
Sep 21, 2009 at 9:14 PM

yes.  The $ in a regex implies "end of string" so often you will see patterns brakcted by ^ (beginning of string) at the beginning, and $ at the end.

in your case it would be

RedirectRule ^/test$ http://www.domain.com/test.aspx [I,R=301]
RedirectRule ^/testing$ http://www.domain.com/testing.aspx [I,R=301]

you could wildcard it with something like this:

RedirectRule ^/(test|testing)$ http://www.domain.com/$1.aspx [I,R=301]
Sep 22, 2009 at 3:20 PM

Fantastic! Thanks so much for your help.