我打印了 $_SERVER,发现 $_SERVER['REDIRECT_URL']
与 $_SERVER['REQUEST_URI']
的值相同。两者有什么区别?
最佳答案
REQUEST_URI 是 HTTP request line 中使用的请求 URI 路径和查询。 . REDIRECT_URL is created by Apache当内部重定向发生时:
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
, 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 只包含 URI 路径。
关于PHP: $_SERVER ['REDIRECT_URL' ] 对比 $_SERVER ['REQUEST_URI' ],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6483912/