Saurabh Sharma Saurabh Sharma - 1 month ago 13
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:

http://localhost/settings/xyz/?ref=menu1&abc=2&de=3..


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

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]
Comments