Jan Lyndon Jasa
Jan Lyndon Jasa

Reputation: 162

url rewrite in web.config

I've been reading articles regarding Url Rewrite in web.config but I don't understand why my redirection doesn't work. Below is my sample url:

localhost/MySite/1542

and here's the pattern I used for matching the url:

<rule name="testRedirect" stopProcessing="true">
   <match url="^/MySite/([0-9]+)" />
   <action type="Redirect" url="/MySite/default.html" />
</rule>

can someone enlighten me what's wrong with my code?

Upvotes: 0

Views: 178

Answers (1)

Rick Su
Rick Su

Reputation: 16440

try removing the leading / in matching url ^MySite/([0-9]+)

<rule name="testRedirect" stopProcessing="true">
   <match url="^MySite/([0-9]+)" />
   <action type="Redirect" url="/MySite/default.html" />
</rule>

Upvotes: 1

Related Questions