How to find the root of a site

Instruction
1

If you use a site management system to administer a web resource, you can open the root folder using the built-in file manager of this system. As a rule, it is enough to go to the file manager page – by default most of them open the directory tree of the site in the root directory. To make sure that this is the case in your system, try going to the upstream directory hierarchy folder – site scripts won’t allow the site administrator to rise above the root directory because this requires a higher level of access.

2

When using the FTP client program installed in the computer to access the site files, the principle of actions when determining the root folder will be exactly the same. After connecting to the server, try rising one level above the default folder in the directory tree. If this fails (the request will be sent, but the active directory will remain the same), then it is the root folder of the site. Server scripts determine it automatically by reading the address from the hosting database based on the user login and password entered during the authorization.

3

It is often necessary to learn the full path to the root folder of the site when running server scripts – for example, for their proper operation when running on a schedule (crontab). More often than others, php is used as a language for writing such scripts, in which you can extract the full path to the root directory of the site from the variable placed in the superglobal array $_SERVER. Use the DOCUMENT_ROOT index to select it in this array. For example, you can display the path to the root folder of a site in an empty page if you run such a php script saved on the server:

<? php echo $_SERVER [ 'DOCUMENT_ROOT ']?

>

Leave a Comment