Query string in rewrite rules

Using more and more rewrite_rules to clean up the URL mess in applications I was wondering how to rewrite an URL like:

/item/view/123?debug=1

to

/index.php?objecttype=item&id=123&debug

My latest approach was to use:

RewriteRule ^([a-z]*)/([0-9]*)$ /index.php?objecttype=$1&id=$2

which unfortunately would ignore the debug parameter.
After looking through the manual again I found the QSA (query string append) option. So now my rule now looks like this:

RewriteRule ^([a-z]*)/([0-9]*)$ /index.php?objecttype=$1&id=$2 [QSA]
Advertisements
This entry was posted in Misc. Bookmark the permalink.

2 Responses to Query string in rewrite rules

  1. Tony says:

    You’ve just highlighted something that is going to make what I am doing right now much easier! Thanks.

  2. Mehul says:

    i tried same but its still ignoring all after “&”
    Any idea write me………….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s