Chris Clarke
Chris Clarke

Reputation: 1

How to mod_rewrite just one querystring parameter?

I would like to rewrite the following URL:

mypage/1234/myaction?api_key=4567

to:

api/myaction.php?id=1234&api_key=4567

...using mod-rewrite. I can get /mypage/1234/myaction -> api/myaction.php?id=1234, but the extra get parameter is causing some problems....

Any ideas?

Upvotes: 0

Views: 150

Answers (1)

Artefacto
Artefacto

Reputation: 97845

Use the QSA (query string append) flag:

RewriteRule mypage/(\d+)/myaction api/myaction.php?id=$1 [QSA]

Upvotes: 2

Related Questions