问题
How to allow few parameters to continue to be redirected while one paramter which is an array to be converted into a string in the url path
example: param1[]=apple&price=1,10 should become /apple/?price=1,10
Orginal url: example.com/path1/?param1[]=apple¶m2=1,100
Expected redirection: example.com/path1/apple/?param2=1,100
Orginal url: example.com/path1/path2/?param[]=apple¶m2=1,100¶m3=yes
Expected redirect: example.com/path1/path2/apple/?param2=1,100¶m3=yes
回答1:
You may use this redirect rule that will handle param1[]= query parameter anywhere:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*&)?param1\[\]=([^&]*)(?:&(.*))?$ [NC]
RewriteRule ^(.*?)/?$ /$1/%2?%1%3 [R=301,NE,L]
来源:https://stackoverflow.com/questions/61133237/rewritecond-fetch-array-parameters-from-query-string-and-convert-into-path-while