0

I would like to make a permanent redirection of

/ask?search%255Bto%255D=test 

to

/question/test

I add in my .htaccess

RewriteCond %{QUERY_STRING} ^search%255Bto%255D=([a-zA-Z0-9\-]*)
RewriteRule ^ask$ /question/%1 [R=permanent,L]

With these additional lines, I get

/ask?search%255Bto%255D=test 

redirect to

/question/test?search%255Bto%255D=test

My problem is than I still have the query string (?search%255Bto%255D=test) in my redirection url.

I would like to have:

/question/test

and not

/question/test?search%255Bto%255D=test

Thanks for any help

1 Answer 1

1

If you want to clear the query string, simply end your target URL with a question mark. Try changing your rewrite rule to:

RewriteRule ^ask$ /question/%1? [R=permanent,L]

This specifies a new, empty query string, so the old one will not be sent as part of the redirect URL.

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.