ComfortablyNumb
ComfortablyNumb

Reputation: 1456

IIS URL Rewrite URLwith Optional Index Page

I've been able to pattern-match a url with or without a trailing slash

<match url="locations/(.+?)/?$" />

However, I want to be able to match locations/[location]/index.aspx as well.

How can I incorporate this optional pattern?

I tried the clumsy:

<match url="(towns/(.+?)/?$)|(towns/(.+?)/index\.aspx$)" />

which wasn't liked at all!

Any help would be appreciated.

Upvotes: 0

Views: 83

Answers (1)

Nefariis
Nefariis

Reputation: 3549

This

(?<=locations\/)(.+?)(?=\/|$|\s)

will match [location] in

/locations/[location]/
/locations/[location]
/locations/[location]/index.aspx
/locations/[location]/anything_on_the_planet.html
/locations/[location] <A bunch of text over here>

If I am understanding your question right you want -

  1. with or without trailing slash
  2. To follow locations/
  3. to work regardless what is on the other side of the [location]

If you need anything else, let me know

Upvotes: 1

Related Questions