John Smith John Smith - 2 months ago 8
Apache Configuration Question

htaccess removes the GET variables

I am editing a script and need to read GET variables to make my job done. But it seems the .htaccess file is manipulating it and removes everything at the end of custom URLs. I have no idea how to modify apache configurations to make it to works fine for the script yet me.

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ index.php?route=$1/$2 [L]
</IfModule>

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L]
</IfModule>


Here is a sample of URL I need to call:

http://domain.tld/controller/plugin/function/route?k1=v1&k2=v2


and the $_GET only contains one 'route' key with the value below:

controller/plugin/function/route


And other query strings are missed. What should I do for having them?

Answer

You probably want the QSA: Query String Append rewrite flag which does what it says on the tin.

For example:

RewriteRule ^(.*)/(.*)$ index.php?route=$1/$2 [L,QSA]

Comments