使用 IIS7 的 URL 重写模块的正则表达式问题
我正在 IIS7 中使用 URL 重写模块并使用用户友好 URL 规则模板。
我正在尝试获取如下 URL:
Something/param1/something/param2/something/param3/something/something2/ etc.etc.
重写为
SomethingEnd.aspx?param1=something¶m2=something¶m3=something/something2& etc.etc.
使用模板,它会自动生成类似以下内容:
^SomethingEnd\.aspx$
重定向到
Something/{C:1}/{C:2}/{C:3}/{C:4}/{C:5}/{C:6} etc.
以及反向为
^Something/([^/]+)/([^/]+)/?$
be
SomethingEnd.aspx?{R:1}={R:2}
我的问题是,如何使其动态化?虽然我的查询字符串中的参数数量有限,但我真的不想这样做,例如,如果我有 6 个参数,则有 6 个单独的重写规则(并且应用相反的规则)。
我尝试过
^Something/([^/]+)*/?$
,但这似乎不起作用。
任何帮助将不胜感激。
谢谢你!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
split
。编辑
举个例子,在 javascript 中,你可以使用这个:
这会返回一个数组:
因此,你只需要一个循环来获取正确的信息。
You can use
split
.EDIT
Just as an example, in javascript, you can use this:
And this returns an array:
So, you need just a loop to get correct information.