Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.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_Get_Difference - Fatal编程技术网

Php .htaccess参数的差异

Php .htaccess参数的差异,php,.htaccess,get,difference,Php,.htaccess,Get,Difference,我有以下访问权限: Options FollowSymlinks RewriteEngine on RewriteRule ^test/(.*)$ index.php?test=$1 [B,NE,QSA] 然后我有以下index.php: print_r($_GET); 结果是: 为什么test和test2是不同的?我希望它们具有相同的值。使用B标志+将不会转换为URI中的空格。首先需要一个附加规则将+转换为空格 RewriteEngine On RewriteBase / # con

我有以下访问权限:

Options FollowSymlinks

RewriteEngine on

RewriteRule ^test/(.*)$ index.php?test=$1 [B,NE,QSA]
然后我有以下index.php:

print_r($_GET);
结果是:

为什么test和test2是不同的?我希望它们具有相同的值。

使用B标志+将不会转换为URI中的空格。首先需要一个附加规则将+转换为空格

RewriteEngine On
RewriteBase /

# convert + to space in URI
RewriteRule ^([^+]+)\+(.*)$ "$1 $2" [L]

# now your original rule
RewriteRule ^test/(.*)$ index.php?test=$1 [B,L,QSA]
现在,您的测试URL将为您提供此$\u GET数组:


最好的解决方案是使用$\u SERVER[REQUEST\u URI]重新生成$\u GET变量。

您想做什么?我正在尝试得到响应:Array[test]=>directeur R&D[test2]=>directeur&D非常感谢您的想法。很高兴知道它成功了,您可以单击我答案左上方的勾号,将答案标记为已接受。
RewriteEngine On
RewriteBase /

# convert + to space in URI
RewriteRule ^([^+]+)\+(.*)$ "$1 $2" [L]

# now your original rule
RewriteRule ^test/(.*)$ index.php?test=$1 [B,L,QSA]
Array
(
    [test] => directeur R&D
    [test2] => directeur R&D
)