Welcome! Log In Create A New Profile

Advanced

Re: Trailing slash being removed from document root

Francis Daly
January 04, 2012 05:58PM
On Wed, Jan 04, 2012 at 05:30:42PM -0500, freejack wrote:

Hi there,

> When getting the document root in PHP from nginx using this:
>
> $_SERVER['DOCUMENT_ROOT']."../".$ZONE."/".$LOCALE...etc......
>
> nginx will always return the path WITHOUT the trailing slash.

nginx doesn't do PHP, it does fastcgi. Which means that it sends a series
of key/value params to the fastcgi server, which in turn presents them
to your PHP in the _SERVER array.

Which in turn means that...

> We have way too much code in php that gets the document root without
> adding a trailing slash after $_SERVER['DOCUMENT_ROOT'] because lighttpd
> and apache before that always had preserved the trailing slash.
>
> How can I configure nginx to keep the slash?

....wherever you currently set "fastcgi_param DOCUMENT_ROOT" (probably from
"include fastcgi.conf"), add the slash there and it all should Just Work.

That is:

you probably have

fastcgi_param DOCUMENT_ROOT $document_root;

Change it to be

fastcgi_param DOCUMENT_ROOT $document_root/;

and on nginx -s reload, you should see the difference.

f
--
Francis Daly francis@daoine.org

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

Trailing slash being removed from document root

freejack January 04, 2012 05:30PM

Re: Trailing slash being removed from document root

Francis Daly January 04, 2012 05:58PM

Re: Trailing slash being removed from document root

freejack January 04, 2012 06:16PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 322
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