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

Is it possible, using regex, to parse the query string and create a good url that can be translated back to an ugly url for use in an outdated application? For example, let's say we are not sure which query string parameters will be part of the 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 a filter so that the application can see it as an old URL for proper processing. Again, we do not know which combination of parameters can be used.

Can this be done only with a filter?

+3
source share
1 answer

, RewriteCompatibility2 on Helicon 3.0, LP ( ).

ReGex QueryString ( : name value )

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

, , - :

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

Source: https://habr.com/ru/post/1740175/


All Articles