Forum Moderators: phranque
to change to
[domain.com...]
I've got everything but the search parameter staying in the query string... Here is the rewrite I came up with
RewriteRule ^(.*)/products/(.*)\.html?search=(.*) /search/products.php?product=$2&city=$1&search=$3
RewriteRule cannot "see" the query string directly, so use RewriteCond [httpd.apache.org] to test and extract it, and back-reference it with "%1" :
RewriteCond %{QUERY_STRING} ^search=([^&]*)
RewriteRule ^([^/]*)/products/([^.]*)\.html$ /search/products.php?product=$2&city=$1&search=%1 [L]
Now, if there are other optional parameters in the query string that I would like to keep in the query string...
example: [domain.com...]
The "origin" and "member" parameters may or may not be there. Do I just have 3 of these?
RewriteCond %{QUERY_STRING} ^search=([^&]*)
RewriteCond %{QUERY_STRING} ^origin=([^&]*)
RewriteCond %{QUERY_STRING} ^member=([^&]*)
and then backreference using %1, %2, and %3 like this?
RewriteRule ^([^/]*)/products/([^.]*)\.html$ /search/products.php?product=$2&city=$1&search=%1&origin=%2&member=%3 [L]
The problem I see is what if the URL has only the member parameter or only the origin or only the search parameter? WHat is if has a combo of the two?
Everything I try keeps erroring out, it seems like I literally have to right a RewriteRule for every permutation?
Try this instead:
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^([^/]*)/products/([^.]*)\.html$ /search/products.php?product=$2&city=$1&%1 [L]
RewriteRule ^([^/]*)/products/([^.]*)\.html$ /search/products.php?product=$2&city=$1 [L]
Jim