Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: $_SERVER['REDIRECT_URL'] vs $_SERVER['REQUEST_URI']

Tags:

php

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?

like image 471
evilReiko Avatar asked Jun 26 '11 12:06

evilReiko


People also ask

What is $_ SERVER Request_uri?

$_SERVER['REQUEST_URI'] contains the URI of the current page. So if the full path of a page is https://www.w3resource.com/html/html-tutorials.php, $_SERVER['REQUEST_URI'] would contain /html/html-tutorials. php.

Is $_ SERVER [' Request_uri '] safe?

In cases where you do need it, the answer is that yes, REQUEST_URI is safe.

What is $_ SERVER [' Script_name ']?

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here.

What is $_ SERVER [' Php_self ']?

$_SERVER['PHP_SELF'] Returns the filename of the currently executing script.


1 Answers

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 a REDIRECT_ prefix, i.e., HTTP_USER_AGENT becomes REDIRECT_HTTP_USER_AGENT.

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.

Note that REDIRECT_URL does only contain the URI path.

like image 164
Gumbo Avatar answered Sep 26 '22 05:09

Gumbo