How To Find The Site Root

Table of contents:

How To Find The Site Root
How To Find The Site Root

Video: How To Find The Site Root

Video: How To Find The Site Root
Video: How to Find the Document Root of your Website 2024, December
Anonim

The root folder of a site is the top-most directory in its hierarchy, in which all other directories are nested. As a rule, when talking about the root folder, they do not mean its http-address displayed in the address bar of the browser, but the full path from the root directory of the server that hosts the site. It's easy enough to get into this folder if you have access to its administration.

How to find the site root
How to find the site root

Instructions

Step 1

If a site management system is used 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 site directory tree in the root directory. To make sure that this is the case on your system, try moving to an upstream folder of the directory hierarchy - site scripts will not allow the site administrator to go above the root directory, as this requires a higher level of access.

Step 2

When using the FTP-client program installed on the computer to access the site files, the principle of actions when defining the root folder will be exactly the same. After establishing a connection to the server, try moving one level up in the directory tree above the folder open by default. If this fails (the request will be sent, but the active directory remains the same), then this is the root folder of the site. Server scripts determine it automatically, reading the address from the hosting database using the username and password entered during authorization.

Step 3

It is often necessary to find out the full path to the root folder of a site when executing server-side scripts - for example, for them to work correctly when launched on a schedule (crontab). More often than others, php is used as the language for writing such scripts, in which you can extract the full path to the root directory of the site from a variable placed in the $ _SERVER superglobal array. To select it in this array, use the DOCUMENT_ROOT index. For example, you can display the path to the root folder of the site in a blank page if you run the following php script saved on the server in your browser:

Recommended: