php - Appending query string through redirect htaccess -
i trying create rewrite cond in htaccess trying redirect
http://www.example.com/business/search-results.php?keywords=animal+business+cards&go=search
to
http://www.example.com/business/search results.php?keywords=animal+business&go=search
or if possible remove word "+cards" search queries...
what have tried far
rewriteengine on rewritecond %{query_string} ^animal+business+cards$ rewriterule ^(.*)$ http://www.example.com/business/search-results.php?keywords=animal+business [r=301,l]
also tried
rewritecond %{query_string} "&go=search" [nc] rewriterule (.*) /$1? [r=301,l]
and this
redirect /business/search-results.php?keywords=animal+business+cards&go=search http://www.example.com/business/search-results.php?keywords=animal+business&go=search
none of these working... possible? can 1 help? thank in advance
try following code :
rewriteengine on rewritecond %{query_string} ^keywords=([^\+]+)\+([^\+]+)\+([^&]+)&go=([^&]+)$ [nc] rewriterule ^ %{request_uri}?keywords=%1+%2&go=%4 [nc,l,r]
another solution
rewriteengine on rewritecond %{the_request} \?keywords=([^\+]+)\+([^\+]+)\+([^&]+)&go=([^&\s]+) [nc] rewriterule ^ %{request_uri}?keywords=%1+%2&go=%4 [nc,l,r]
note : redirect directive not support querystrings in old path perameter, why last attempt failed. can use %{query_string} or %{the_request} variable match against urls query strings.
Comments
Post a Comment