PHP:$ _ SERVER ['REDIRECT_URL']与$ _SERVER ['REQUEST_URI'] [英] PHP: $_SERVER['REDIRECT_URL'] vs $_SERVER['REQUEST_URI']
问题描述
我打印了$ _SERVER,发现$ _SERVER['REDIRECT_URL']
与$_SERVER['REQUEST_URI']
都具有相同的值.两者有什么区别?
I printed $_SERVER, and I found out that $_SERVER['REDIRECT_URL']
vs $_SERVER['REQUEST_URI']
both have same values. What's the difference between the two?
推荐答案
REQUEST_URI 是在HTTP请求行.内部重定向发生时, REDIRECT_URL 由Apache 创建:
REQUEST_URI is the requested URI path and query as used in the HTTP request line. REDIRECT_URL is created by Apache when an internal redirect happens:
REDIRECT_
环境变量是根据重定向之前存在的环境变量创建的.它们使用REDIRECT_
前缀重命名,即HTTP_USER_AGENT
变为REDIRECT_HTTP_USER_AGENT
.
REDIRECT_
environment variables are created from the environment variables which existed prior to the redirect. They are renamed with aREDIRECT_
prefix, i.e.,HTTP_USER_AGENT
becomesREDIRECT_HTTP_USER_AGENT
.
REDIRECT_URL
,REDIRECT_STATUS
和REDIRECT_QUERY_STRING
,并且只有在错误条件之前存在其他标头时,才会设置其他标头.
REDIRECT_URL
, REDIRECT_STATUS
, and REDIRECT_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 仅包含URI路径.
Note that REDIRECT_URL does only contain the URI path.
这篇关于PHP:$ _ SERVER ['REDIRECT_URL']与$ _SERVER ['REQUEST_URI']的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!