Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.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 为什么要修改请求URI?_Php - Fatal编程技术网

Php 为什么要修改请求URI?

Php 为什么要修改请求URI?,php,Php,在req.php中运行以下代码时: <?php echo("Request:\n"); print_r($_SERVER['REQUEST_URI']); ?> 我得到的答复是: Request: /req.php/postcode/14482/city/country/de/ 当我在/city后面使用两个点时: Request: /req.php/postcode/14482/country/de/ Request: /req.php/postcode/14482/c

在req.php中运行以下代码时:

<?php
  echo("Request:\n");
  print_r($_SERVER['REQUEST_URI']);
?>
我得到的答复是:

Request:
/req.php/postcode/14482/city/country/de/
当我在/city后面使用两个点时:

Request:
/req.php/postcode/14482/country/de/
Request:
/req.php/postcode/14482/city/.../country/de/
在/city后面加上三个点:

Request:
/req.php/postcode/14482/country/de/
Request:
/req.php/postcode/14482/city/.../country/de/
为什么请求的URI被修改而不是未经处理的传递

编辑:看来cURL正在编辑请求URI-cURL php库中是否有任何设置来禁用此行为

为什么请求的URI被修改而不是未经处理的传递

事实并非如此。URL的更改是由cURL在它靠近服务器之前进行的。发送到服务器的请求中从不包含
/

/
表示“当前路径段”,因此它是冗余的。客户机(cURL)在发出请求之前正在对其进行规范化

通过将带有
curl
的请求响应与手动构造HTTP请求时的响应进行比较,可以看出这一点

手动构造的请求 卷曲
%  curl http://localhost:7007/index.php/req.php/postcode/14482/city/./country/de/
Request:
/index.php/req.php/postcode/14482/city/country/de/