Welcome! Log In Create A New Profile

Advanced

Re: Problem with $_SERVER['REQUEST_URI'];

Maxim Dounin
June 05, 2011 05:30PM
Hello!

On Sun, Jun 05, 2011 at 04:22:40PM -0400, etrader wrote:

> In my nginx server, $_SERVER['REQUEST_URI']; does not work, and returns
> nothing. When using getenv("REQUEST_URI"); it will returns the url of
> the current page instead of the reffering url. And in this case, it will
> return the current filename (e.g. /test.php) not the full url. I have

REQUEST_URI is expected to contain URI used to access the page in
question. I.e. it's expected to contain '/test.php' if you access
'/test.php' URI. Note that HTTP historically uses only absolute
path on an origin server as URI, not the absolute URL.

Reffering url may (or may not) be present in Referer header, which
should be available in php as HTTP_REFERER.

> tested this on apache, and there is no problem; thus it is something
> related to nginx setting. Any idea?

nginx doesn't execute php scripts by itself, it only passes
requests to backend you configured (via one of the supported
protocols, that is http, fastcgi, ...).

As you see getenv("REQUEST_URI") but not $_SERVER['REQUEST_URI'] -
it looks like data is available on your backend, but for some
reason only via getenv(), not $_SERVER[]. Check your php backend
to find out why this happens.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Problem with $_SERVER['REQUEST_URI'];

etrader June 05, 2011 04:22PM

Re: Problem with $_SERVER['REQUEST_URI'];

Maxim Dounin June 05, 2011 05:30PM

Re: Problem with $_SERVER['REQUEST_URI'];

etrader June 05, 2011 06:45PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 247
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready