Answer the question
In order to leave comments, you need to log in
How to make a redirect with get parameters to without them except utm tags?
It is necessary that in links of the form
https://site.ru/?_escaped_fragment_=annatrish/oss8q
https://site.ru/?cat=3
/?feed=comments-rss2
RewriteCond %{REQUEST_URI} !^utm
RewriteCond %{QUERY_STRING} ^(.+) [NC]
RewriteRule ^(.*)$ /$1? [R=301,L]
Answer the question
In order to leave comments, you need to log in
I can tell you how to do all this in JavaScript:
<script>
window.history.replaceState('', '', location.pathname);
</script>
Rule of thumb if anyone needs it
# check that there is indeed a query string
RewriteCond %{QUERY_STRING} ^.+$
# check that it doesn't start with one of allowed parameters
RewriteCond %{QUERY_STRING} !^(utm_source)= [NC]
RewriteRule ^(.*)$ /$1? [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question