RewriteCond从Query_String中获取数组参数并转换为路径,同时保留其余参数 [英] RewriteCond fetch array parameters from Query_String and convert into path while retaining the remaining parameters
本文介绍了RewriteCond从Query_String中获取数组参数并转换为路径,同时保留其余参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在将一个参数(数组)转换为url路径中的字符串的同时,允许很少的参数继续重定向
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
示例:param1 [] = apple& price = 1,10应该变成/ apple /?price = 1,10
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
推荐答案
您可以使用此重定向将在任何地方处理 param1 [] =
查询参数的规则:
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]
这篇关于RewriteCond从Query_String中获取数组参数并转换为路径,同时保留其余参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文