haibuihoang
haibuihoang

Reputation: 171

Forward QUERY_STRING in .htaccess url rewrite

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!

Upvotes: 0

Views: 44

Answers (1)

ôkio
ôkio

Reputation: 1790

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

Upvotes: 2

Related Questions