0

Suppose I want to rewrite from

http://example.com/test?data=abcxyz

to

 http://example.com/index.php?module=test&data=abcxyz

I tried

RewriteRule ^test?(.*)$ index.php?module=test&$1 [L]

But it doesn't work, the QUERY_STRING becomes module=test&s. (The whole string data=abcxyz become s). How can I accomplish this task? Many thanks in advance!

1 Answer 1

2

There is a flag to this, the QSA flag :)

RewriteRule ^test?(.*)$ index.php?module=test&$1 [L,QSA]

Explanation from here : Apache doc

When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combin

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

2 Comments

Thank you very much! Stackoverflow is such an awesome place!
"QSA" is the key

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.