Reputation: 35
I want to remove 2 symbols "?&" from link https://www.example.com/?& by redirect it to https://www.example.com/.
I tried this
RewriteCond %{QUERY_STRING} "&" [NC]
RewriteRule (.*) /$1? [R=301,L]
It worked but it removed also any really QUERY like https://www.example.com/?set=down&page=3
Upvotes: 0
Views: 44
Reputation: 675
Below is the working rule
RewriteEngine on
RewriteCond %{QUERY_STRING} ^&$
RewriteRule (.*) /? [R=301,L,NE]
You can test the same at result
In this solution we have matched the query string
such that it if starts with & and ends afterwards
then only rewrite happens.
For urls like https://www.example.com/?set=down&page=3
the rewrite condition fails and hence no redirection happens.
Upvotes: 1