Home >Backend Development >PHP Tutorial >How does RewriteCond obtain multiple parameters in pseudo-static rules?
The following form rules exist:
/index.php?m=search&c=index&s=1&t=1&k=Keywords
I want to forward the path to
/search?s=1&t=1&k=Keywords
You can only get one parameter value using the following method
RewriteCond %{QUERY_STRING} ^k=(.+)$
RewriteRule ^search$ /index.php?m=search&c=index...&k=%1
If you use the following method to obtain multiple parameters, the order of the parameters is fixed. Once the order is changed, it will not work.
RewriteCond %{QUERY_STRING} ^k=(.+)&s=(.+)&c=(.+)$
RewriteRule ^search$ /index.php?m=search&c=index...&k=%1&s=%2&c=%3
If you use the following method, there is a security risk, and the number of parameters cannot be limited
RewriteRule ^search$ /index.php?m=search&c=index [L,QSA]
Please ask the experts for any good solutions?
The following form rules exist:
/index.php?m=search&c=index&s=1&t=1&k=Keywords
I want to forward the path to
/search?s=1&t=1&k=Keywords
You can only get one parameter value using the following method
RewriteCond %{QUERY_STRING} ^k=(.+)$
If you use the following method to obtain multiple parameters, the order of the parameters is fixed. Once the order is changed, it will not work.
RewriteCond %{QUERY_STRING} ^k=(.+)&s=(.+)&c=(.+)$
If you use the following method, there is a security risk, and the number of parameters cannot be limited
Please ask the experts for any good solutions?
Parameters such as
k
s
c
<code>RewriteCond %{QUERY_STRING} ^([a-z]+)=(.+)&([a-z]+)=(.+)&([a-z]+)=(.+)$ RewriteRule ^search$ /index.php?m=search&c=index...&%1=%2&%3=%4&%5=%6</code>