0

its possible to create a redirection, but preserve the query string?

example, the original URL :

`http://example.com/listing/?search_query=anykeyw&tax_location=newyork&wpas=1`

redirect to page

 `http://example.com/new-york/?search_query=anykeyw`

preserve the ?search_query=anykeyw, that contains keyword for ads and listings kewywords...

any suggestions?

  • Use the `QSA` flag in your rewrite and it will send them in the request. – Panama Jack Jan 30 '15 at 20:08
  • http://stackoverflow.com/questions/12873137/how-can-i-mod-rewrite-and-keep-query-strings – error Jan 30 '15 at 20:09
  • yes i use the `QSA` but the location dinamically changes after a submit a search form... i think first i need get string from URL `tax_location=newyork` THEN redirect to new-york.php page... its that possible? – user3250798 Jan 30 '15 at 20:20

1 Answers1

0

You can use this in your root .htaccess:

RewriteCond %{QUERY_STRING} tax_location=newyork [NC]
RewriteCond %{QUERY_STRING} search_query=([^&]*) [NC]
RewriteRule ^listing/$ new-york/?search_query=%1 [NC,R,L]
Croises
  • 18,570
  • 4
  • 30
  • 47