Ive come across this a few times, and I cannot figure it out.
I usually find out where the site is installed using $_SERVER['DOCUMENT_ROOT'], however on some servers it reports the htdocs folder its in, on other it reports its parent folder.
Is there a more reliable way of finding out where the site is located so I can navigate up and go into folders no part of htdocs. For example uploads.
Thank you in advance
PHPApache Web Server
Last Comment
Julian Hansen
8/22/2022 - Mon
Bembi
Everything you can see from the web site perspective is ralative to your own root path. If you want to now what is behind it, you have to go behind the sceenes and inspect the connected php settings. I would assume, this you will not be able to see, but your provider may possibly tell you. The php documents root is either a general php directrive or - as far as your provider allows to change it - a web specific directrive. This can differ of course form provider to provider. But what you get from the web site perspective is what your provider defined (at least as default) for your webspace.
For the webspace it doesn't play a role at the end, sometimes you just have to know it to be aware how to setup some services. So my question would be, what makes the difference for you?
Dave Baldwin
Some hosts allow you complete access up to your Linux 'home' directory. But a lot of hosting companies restrict your access to your own web folders. Even FTP is not going to show you anything 'above' that.
David Favor
1) You asked, "Is there a more reliable way of finding out where the site is located".
Yes.
Always your Webserver config file.
PHP directories... can be... confusing/jumbled/broken...
Your Webserver config is the definitive source of your DocumentRoot location.
2) You asked, "Is there a more reliable way of finding out where the site is located so I can navigate up and go into folders no part of htdocs. For example uploads."
To little data to answer this.
Find site == Webserver config.
Navigate Up == How this occurs relates to your Webserver config + any code (PHP or other) running on your site.
folders no part of htdocs == Unsure what this might mean.
uploads == Start with your Webserver config + then your full URL + refer to your Webserver logs, if an error occurs.
If you want to now what is behind it, you have to go behind the sceenes and inspect the connected php settings.
I would assume, this you will not be able to see, but your provider may possibly tell you.
The php documents root is either a general php directrive or - as far as your provider allows to change it - a web specific directrive. This can differ of course form provider to provider.
But what you get from the web site perspective is what your provider defined (at least as default) for your webspace.
For the webspace it doesn't play a role at the end, sometimes you just have to know it to be aware how to setup some services. So my question would be, what makes the difference for you?