Current htaccess block :
# redirect "/search/location.php?state=x&city=x&name=x" to "/search/state/city/name/"
RewriteCond %{THE_REQUEST} \s/search/location.php\?state=(.+)&city=(.+)&name=(.+)\s [NC]
RewriteRule ^ /search/%1/%2/%3/? [R=301,L]
#### internally rewrite "/search/state/city/name/" to "/search/location.php?state=x&city=x&name=x"
RewriteRule ^search/(.+)/(.+)/(.+)/$ /search/location.php?state=$1&city=$2&name=$3 [L]
https://example.com/search/location.php?state=florida&city=Orlando&name=test
correctly redirects to https://example.com/search/florida/orlando/test/
https://example.com/search/location.php?state=florida&city=Orlando&name=test&something=something
incorrectly redirects to https://example.com/search/florida/orlando/test&something=something/
What I want to achieve is redirecting to https://example.com/search/florida/orlando/test/?something=something
What am I missing here? Keep in mind I am doing an internal as well.
https://example.com/search/florida/orlando/test/&something=somethingdoes not really make sense. There is no query string in there, but an ampersand notation.name=to be accepted as parameter value forname. So that is what happens. I would suggest to change the matching pattern to something like that:\s/search/location.php\?state=([^&]+)&city=([^&]+)&name=([^&]+)(.*)\s, whoch captures anything following thenameparameter value as a fourth capture group which you then can use however you like.https://example.com/search/florida/orlando/test/?something=somethingas desired url. Sorry for the mistake.