I'm trying to add an anchor to an URL with a query string. The original URL is
https://example.com/foo?query=123
It should redirect to
https://example.com/foo?query=123#anchor
These are my Rules in the .htaccess file:
RewriteCond %{REQUEST_URI} ^/foo$
RewriteCond %{QUERY_STRING} ^query=[a-zA-Z0-9\s]*$
RewriteRule (.*) /foo?%{QUERY_STRING}#anchor [NC,NE,R=302,L,END]
Do you have an idea how to avoid the redirecting loop?