Reputation: 1710
I was attempting to redirect
/KEY/TEXT or
/KEY/WEB.ASPX
to redirector?key=KEY&url=TEXT or redirector?key=KEY&url=WEB.ASPX respectively.
I managed to gain success for /KEY in which I wrote the following in my web.config
<match url="^([a-zA-Z0-9_-]+)$" ignoreCase="false" />
<action type="Rewrite" url="/redirector.aspx?key={R:1}" appendQueryString="false" />
however whichever way I attemped to match the URL for /TEXT or /WEB.ASPX I was not able to get. I even attempted
<match url="^([a-zA-Z0-9_-]+)(\\/)([a-zA-Z0-9_-]+)$" ignoreCase="false" />
<action type="Rewrite" url="/redirector.aspx?key={R:1}&url={R:2}" appendQueryString="false" />
Anyone could highlight what went wrong in the following request?
Thanks!
Upvotes: 1
Views: 750
Reputation: 15663
<match url="^([a-zA-Z0-9_\-]+)/+([a-zA-Z0-9_\-\.]+)$" ignoreCase="false" />
<action type="Rewrite" url="/redirector.aspx?key={R:1}&url={R:2}" />
See the differences
/KEY/TEXT
and ignore urls like /KEY/
&
This is a rewrite rule, that means you would still see the url in browsers nav bar. If you want to redirect to redirector.aspx, then you have to use type="Redirect"
Upvotes: 2