Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.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/6.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 这条接入线怎么了_Php_.htaccess - Fatal编程技术网

Php 这条接入线怎么了

Php 这条接入线怎么了,php,.htaccess,Php,.htaccess,我的.htaccess中有这些行 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^restaurant_pos$ index.php?route=$1 [L] 但是如果您访问该站点,您将看到左上角的MyPHP调试语句 echo print_r($_REQUEST); 哪张照片 Array ( [route] => ) 为

我的.htaccess中有这些行

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^restaurant_pos$ index.php?route=$1 [L]
但是如果您访问该站点,您将看到左上角的MyPHP调试语句

echo print_r($_REQUEST);
哪张照片

Array
(
    [route] => 
)
为什么它是空的…这会导致问题…我做错了什么

尝试使用$0。或者,尝试在$1中应该包含的内容周围添加一个捕获组括号

尝试改用$0。或者,尝试在$1中应该包含的内容周围添加一个捕获组括号


您正在引用一个不存在的替换变量$1。它们是用括号定义的,如下所示:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^restaurant_pos_([0-9]+)$ index.php?route=$1 [L]
例如,这将在restaurant_pos之后匹配url中的一个数字,并将其放入GET参数路由中

将导致

index.php?route=1234
或者,如果您正试图获得一切:

RewriteRule ^(.*)$ index.php?route=$1

应返回GET参数路由中域名后的所有内容。

您引用的是一个不存在的替换变量$1。它们是用括号定义的,如下所示:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^restaurant_pos_([0-9]+)$ index.php?route=$1 [L]
例如,这将在restaurant_pos之后匹配url中的一个数字,并将其放入GET参数路由中

将导致

index.php?route=1234
或者,如果您正试图获得一切:

RewriteRule ^(.*)$ index.php?route=$1
应返回GET参数路由中域名后的所有内容。

替换

RewriteRule ^restaurant_pos$ index.php?route=$1 [L]

替换

RewriteRule ^restaurant_pos$ index.php?route=$1 [L]


$1是您试图分配路线参数的值吗?我要分配餐厅_pos@Tamer如果您想将restaurant_pos分配给$1,那么必须将其放在括号中^restaurant_pos$index.php?route=$1[L]所以括号使$1可用…所以如果我有两个括号,那么我可以引用$2 im猜测$1是你试图分配路线参数的值吗?我想分配餐厅_pos@Tamer如果您想将restaurant_pos分配给$1,那么必须将其放在括号中^restaurant_pos$index.php?route=$1[L]所以括号使$1可用…所以如果我有两个括号,那么我可以参考$2即时消息猜测括号使$1可用…所以如果我有两个括号,那么我可以参考$2是的。用于匹配条件,因此,例如^.*/*$将允许您重写为index.php?route=$1和second=$2所以,如果我有两个括号,那么我可以引用$2是。用于匹配条件,例如^.*/*$将允许您重写为index.php?route=$1和second=$2