开发者

ISAPI rewrite (using Helicon on IIS and ASP.NET) and dynamic query string append?

Is it possible, using regex, to parse the query string and build a nice URL that can be translated back to the ugly URL for use on a legacy application? For example, let's say we are not certain what q开发者_JAVA百科uery string parameters are going to be part of a URL. Here is an example:

http://www.domain.com/thePage.aspx?Param1=1&Param2=23&Param7=22

We want to rewrite the URL as

http://www.domain.com/Param1/1/Param2/23/Param7/22

At the same time we need the filter to allow the application to see it as the old URL to be processed correctly. Again, we don't know what combination of parameters may be used.

Can this be done only using the filter?


As official forums said, you can use RewriteCompatibility2 on in Helicon 3.0, so you can use a LP directive (looping with the replace).

I use this ReGex to parse QueryString (it makes two groups: name with all parameter names, and value with all parameter values)

[\?&](?<name>[^&=]+)=(?<value>[^&=]+)

Based on mentioned forum topic, I think you should try something like this:

//for replacing '='
RewriteRule ^[\?&]([^&=]+)=([^&=]+)$ $1/$2 [LP,R=301,L]
//for replacing '&'
RewriteRule ^\?([^&]+)&([^&]+)$ $1/$2 [LP,R=301,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜