Forum Moderators: phranque
<form method="get" action="/products/search">
</form>
below is what i am using to do the redirect which works but the query string stays the same as the original one even when I select a different option from one of the drop down boxes on the form and re-submit the form.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /products/search\?state_id=([^&\ ]+)&city_id=([^&\ ]+)\ HTTP/
RewriteRule ^.*search$ /index.php?state_id=%1&city_id=%2 [L]
the redirect happens every time i submit the form but the query string does not get updated in the browser address bar. I don't have any other rules in my .htaccess file
Much Regards,
Chris
RewriteCond %{QUERY_STRING} ^state_id=[^&]+&city_id=[^&]+
RewriteRule search$ /index.php [L]
Also, note that the original query string will be passed through unmodified, as was done (albeit the hard way) with the original code.
If "search" is *always* called with both state_id and city_id in that order, then you may delete the RewriteCond entirely. The function would then be simplified to rewriting any request for "search" in any directory to a request for index.php in the Web root directory, carrying any existing query string forward.
Jim
the issue i have now is that if a user changes the order of the parameters in the query string (search?city_id=3&state_id=5) then the condition below will no longer be matched
RewriteCond %{QUERY_STRING} ^state_id=[^&]+&city_id=[^&]+
RewriteRule search$ /index.php [L]
Much Regards,
Chris
If you do not need to know there is an exact match in the query_string, but need to know a query_string exists, you could use the condition:
RewriteCond %{QUERY_STRING} .
This would match any single character, so you know there is a query_string, and you can pass all information to your index.php for processing.
Justin