Reputation: 3
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]
Upvotes: 0
Views: 42
Reputation: 626689
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.
Upvotes: 1