I printed $_SERVER, and I found out that $_SERVER[\'REDIRECT_URL\']
vs $_SERVER[\'REQUEST_URI\']
both have same values. What\'s the difference betw
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_
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.
Note that REDIRECT_URL does only contain the URI path.
$_SERVER['REDIRECT_URL']
is only available on some servers in some cases. Use $_SERVER['REQUEST_URI']
instead.
REQUEST_URI also changes special chars like spaces to "%20" etc.