0

I want to redirect a url with any query string to its original url.

Something like:

mysite.com/?any=query -> mysite.com/
mysite.com/page/?any=query&more=query -> mysite.com/page/

I'm already using this rules to redirect any file to index.php on root directory.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?pagina=$1

1 Answer 1

1

You can use:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?pagina=$1 [L]

RewriteCond %{QUERY_STRING} ^.+$
RewriteRule !^index\.php %{REQUEST_URI}? [R=301,NE,L]
Sign up to request clarification or add additional context in comments.

1 Comment

hi, thanks for the help...but it worked only for root url: mysite.com/?any=query -> mysite.com/ WORKS ...but when i have one or more subdirs after root url it isnt working: mysite.com/page/?any=query -> mysite.com/page/?any=query NOT WORKING

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.