1

I know with a simple redirect one (Sub-)Domain or Folder to another i can get rid of a string like this

RewriteEngine On
RewriteRule (.*) http://www.domain.tld/? [R=301,L]

I know how to get rid of it when it is a simple file too.

But when it comes to the Rootdomain itself (http://domain.tld/?Stringwhatsoever), i am at a loss here. My last try used a modified version of a redirect I used to redirect files and folders around and that worked pretty nicely and also removed the query, but it ended up in a redirection error.

RewriteRule ^ http://domain.tld/? [L,NC,R=301]

So i have no clue how to get rid of Query Strings at urls without breaking it.

1 Answer 1

1

Try this :

RewriteEngine On
RewriteCond %{THE_REQUEST} /\?([^\s]+) [NC] 
RewriteRule ^$ http://domain.com/? [NC,R,L]

Or

RewriteEngine On
RewriteCond %{QUERY_STRING} (.+) [NC] 
RewriteRule ^$ http://domain.com/? [NC,R,L]

Reference :

-https://wiki.apache.org/httpd/RewriteQueryString

Sign up to request clarification or add additional context in comments.

2 Comments

Great, i'll try as soon as possible to fix my site and to see if I get it done. Thank you already now for the help!
Found the Domain that had the Error and the first Rule seems to have worked like a charm!! (Too late to edit my previous Comment :( )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.