Saurabh Sharma Saurabh Sharma - 1 year ago 87
PHP Question

Mod_rewrite handling extra get variables (QSA not working)

I have a mod rewrite rule for settings page: (localhost/settings/index.php)

RewriteRule settings/([a-zA-Z0-9_]+)/?$ settings/?path=$1 [QSA,L]

And I am handling menu references within the URL which will be similar to:


However, with my current rewrite rule, the variable does not get passed along and I didn't get the values of ref,abc..

I read here about QSA flag but that doesn't seem to be working.

What am I doing wrong?

Answer Source

Try turning off MultiViews option:

Options -MultiViews
RewriteEngine On

RewriteRule ^settings/([\w-]+)/?$ settings/?path=$1 [QSA,L,NC]

In place of QSA, you can use this trick to captured query string:

RewriteRule ^settings/([\w-]+)/?$ settings/?path=$1&%{QUERY_STRING} [L,NC]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download