To avoid recursion, you should check the query string , since the query string in %{QUERY_STRING}can already be changed by another rule:
RewriteCond %{THE_REQUEST} ^GET\ /\?(([^&\s]*&)*)tag=([^&\s]+)&?([^\s]*)
RewriteRule ^(.*)$ /tag/%3?%1%4 [L,R=301]
Then you can rewrite the queries back inside without conflict:
RewriteRule ^tag/(.*) index.php?tag=$1 [L]
source
share