0

I want to redirect some url, but got some problem with it. The urls like:

/sample?back=my-account
/sample?back=history
/sample?back=addresses

And need to redirect to

/sample

My last try was this (but didn't work):

RewriteCond %{QUERY_STRING} ^?back=history$
RewriteRule ^sample$ /sample [R=301,L]
1
  • 1
    What about ^sample/?back=? Commented Apr 27, 2015 at 9:04

1 Answer 1

1

You can use this fix:

RewriteCond %{QUERY_STRING} ^back=
RewriteRule ^sample$ /sample? [R=301,L]

This will redirect http://example.com/sample?back=my-account to http://example.com/sample.

Apparently, your condition was not met since the query string starts with back, and to get rid of the query string, you need to add ? to the end of replacement string.

Apache Module mod_rewrite documentation:

When you want to erase an existing query string, end the substitution string with just a question mark.

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

Comments

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.