The URL(s) like below (there are 2 websites, one with www and other without it)
https://example1.com/any-path-here/?_gl=1*um0ntk*_ga*YW1wLUVyYS1QbHgwcFp1SEJBYVlGSlNYdWNQUWIxNGVxY2VhakRDNDUtYmJUZWZPV1M2WEdWN2s2dXVRNzNZWGNTdkk
https://www.example2.com/hello-how-are-you-today/?_gl=1*1lcwex2*_ga*YW1wLXBtWXdrdWNEcTRjTVcwWjMzTzJwNEdJeU5vTmo5UVF0RmFhTEdpbkdMdjgyLXRNQXJaM21oRGpUX2ppSnB3dGs
should redirect to
https://example1.com/any-path-here/
https://www.example2.com/hello-how-are-you-today/
Only the _gl= seems to be constant.
I have tried:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} _gl=
RewriteRule ^ %{REQUEST_URI}? [L,R]
</IfModule>
And
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^_gl=*
RewriteRule ^ %{REQUEST_URI}? [L,R]
</IfModule>
And other rules. But nothing seems to work.
I hope the solution won't mess up the naked domain redirect and https redirect.