[英]PHP: $_SERVER['REDIRECT_URL'] vs $_SERVER['REQUEST_URI']
I printed $_SERVER, and I found out that $ _SERVER['REDIRECT_URL']
vs $_SERVER['REQUEST_URI']
both have same values. 我打印了$ _SERVER,我发现$ _SERVER['REDIRECT_URL']
vs $_SERVER['REQUEST_URI']
都有相同的值。 What's the difference between the two? 这两者有什么区别?
REQUEST_URI is the requested URI path and query as used in the HTTP request line . REQUEST_URI是HTTP请求行中使用的请求URI路径和查询。 REDIRECT_URL is created by Apache when an internal redirect happens: 当内部重定向发生时,Apache会创建REDIRECT_URL :
REDIRECT_
environment variables are created from the environment variables which existed prior to the redirect.REDIRECT_
环境变量是根据重定向之前存在的环境变量创建的。 They are renamed with aREDIRECT_
prefix, ie,HTTP_USER_AGENT
becomesREDIRECT_HTTP_USER_AGENT
. 它们使用REDIRECT_
前缀重命名,即HTTP_USER_AGENT
变为REDIRECT_HTTP_USER_AGENT
。
REDIRECT_URL
,REDIRECT_STATUS
, andREDIRECT_QUERY_STRING
are guaranteed to be set, and the other headers will be set only if they existed prior to the error condition. 保证设置REDIRECT_URL
,REDIRECT_STATUS
和REDIRECT_QUERY_STRING
,并且只有在错误条件之前存在其他标题时才会设置其他标题。
Note that REDIRECT_URL does only contain the URI path. 请注意, REDIRECT_URL仅包含URI路径。
$_SERVER['REDIRECT_URL']
is only available on some servers in some cases. $_SERVER['REDIRECT_URL']
仅在某些情况下可用于某些服务器。 Use $_SERVER['REQUEST_URI']
instead. 请改用$_SERVER['REQUEST_URI']
。
REQUEST_URI还将空格等特殊字符更改为“%20”等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.