.htaccess: GET 变量在重写时丢失

问题描述:

显然,我的 .htaccess 重写占用了我页面上的所有 $_GET 变量:

Apparently, my .htaccess rewrite eats up all $_GET-variables on my page:

访问 URL 时 http://192.168.1.1/welcome/test?getvar=true 并在我的 index.php 文件中运行 var_dump($_GET),我得到这个输出:

When accessing the URL http://192.168.1.1/welcome/test?getvar=true and running var_dump($_GET) in my index.php file, I get this this output:

array
'/welcome/test' => string '' (length=0)

所以没有 $_GET 数据可用,也没有来自我的 URL 的 getvar 变量的迹象.

So no $_GET-data available and no sign of the getvar-variable from my URL.

这是我的 .htaccess:

Here's my .htaccess:

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

我应该更改什么以确保我的重写按预期工作但 $_GET 变量仍然可以访问?

What should I change to ensure that my rewrite is working as intended but $_GET-variables still are accessible?

您需要QueryString Append"选项:

You need the "QueryString Append" option:

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

添加@DonSeba 的贡献,因为它是正确的.

Added @DonSeba's contribution, because it is correct.