DudeOnRock
DudeOnRock

Reputation: 3831

query string gets ignored after mod_rewrite

I am using the following rewrite rule in my .htaccess file to send all requests to the index.php file located at the root:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?q=$1 [L]

As I expected, urls like example.com/users will result in php receiving ["q"]=> string(5) "users" as a $_GET variable.

URLs like example.com/users?fu=bar on the otherhand will not result in php receiving

["q"]=> string(5) "users", 
["fu"]=> string(3) "bar"

What is happening here, and how do I modify my rule to behave that way?

Upvotes: 2

Views: 108

Answers (1)

jeroen
jeroen

Reputation: 91742

You need to add the original query string:

RewriteRule (.*) index.php?q=$1 [L,QSA]
                                   ^^^ here

Upvotes: 3

Related Questions