I'm using URL Rewrite module in IIS7 and using the User Friendly URL Rule template.
I'm trying to get URLs like:
Something/param1/something/param2/something/param3/something/something2/ etc.etc.
to rewrite to
SomethingEnd.aspx?param1=something¶m2=something¶m3=something/something2& etc.etc.
Using the templates, it automatically generates something like:
^SomethingEnd\.aspx$
to redirect to
Something/{C:1}/{C:2}/{C:3}/{C:4}/{C:5}/{C:6} etc.
and the reverse to be
^Something/([^/]+)/([^/]+)/?$
to be
SomethingEnd.aspx?{R:1}={R:2}
My problem is, how can I make it dynamic? Though there is a finite amount of params I have in my query string, I really don't want to make, for example, if I have 6 params, 6 separate rewrite rules (and the reverse applied).
I tried
^Something/([^/]+)*/?$
but that doesn't seem to work.
Any help would be greatly appreciated.
Thank you!
You can use split
.
EDIT
Just as an example, in javascript, you can use this:
"Something/param1/something/param2/something/param3/something/something2/".split(/([^/]+)\/([^/]+)/)
And this returns an array:
["", "Something", "param1", "/", "something", "param2", "/", "something", "param3", "/", "something", "something2", "/"]
So, you need just a loop to get correct information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.