Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess重定向丢失获取变量_Php_.htaccess - Fatal编程技术网

Php .htaccess重定向丢失获取变量

Php .htaccess重定向丢失获取变量,php,.htaccess,Php,.htaccess,这是我为MVC设置的htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?url=$1 [PT,L] </IfModule> 重新启动发动机

这是我为MVC设置的htaccess

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

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?url=$1[PT,L]
因此,对localhost/users/的任何请求都将重定向到localhost?url=users/

但是当url中有一些get数据可用时,例如:localhost/users/?msg=hello

我在$\u GET['url']中缺少了?msg=hello。是否可以重定向到localhost/users/msg=hello/

使用
“QueryString Append”
选项

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

引用自:

您试图做的事情将非常复杂。作为替代方案,您可以尝试以下方法:

RewriteRule ^(.*)$ index.php/$1 [PT,L]
使用该规则时,您可以通过$\u服务器['REQUEST\u URI']访问URL

丢失get参数的原因是服务器使用两个“?”创建URL。例:

http://localhost/?url=users/?msg=123