Eduardo Ponce de Leon
Eduardo Ponce de Leon

Reputation: 9706

Obtain url get variables when htaccess is already creating a query string

I have a rule in .htaccess that generates a query string according to the url syntax:

RewriteEngine on
RewriteRule a_([0-9]+)_(.*).html$ article.php?id=$1 [L]

So a url like this:

a_52_how-to-use-htaccess.html generates: article.php?id=52

My question is how to allow htaccess to add to the query string other get variables sent on the url:

a_52_how-to-use-htaccess.html?debug=true

in order to have:

article.php?id=52&debug=true

Any ideas? Thanks.

Upvotes: 1

Views: 40

Answers (1)

anubhava
anubhava

Reputation: 785651

Use QSA flag:

RewriteEngine on
RewriteRule a_([0-9]+)_(.*)\.html$ article.php?id=$1 [L,QSA]
  • QSA (Query String Append) flag preserves existing query parameters while adding a new one.

Upvotes: 1

Related Questions