2.4.1.1.2. Site root directory
Standard paths
The root directory of the hosting account contains directories with the names of the main domains, within each of which are the directory of the main domain and the directories of its subdomains. On the diagram: ~ — hosting account root directory, example.com — main domain name directory, www — main domain files directory, sub — subdomain sub files directory.
The directory of the main domain is always www (the path to it looks like ~/example.com/www). Although the directory has this name, the work of the main domain with or without www is not related to it and is configured in other ways: via control panel (see Configuring redirect to address with or without www), .htaccess or admin panel of CMS used on the site.
The directory names of subdomains correspond to the names of subdomains without the main domain (e.g., for the sub.example.com subdomain, the directory would be named sub and the path would look like ~/example.com/sub).
Change
Important points:
- The specified directory must be within the standard root directory of the site. It is allowed to specify subdirectories.
- To point multiple domains to a single site, use aliases.
- Open the "Site settings" section.
- In the "Root directory" field, specify the name of the subdirectory and save your changes:

- Wait a few minutes for the changes to take effect.
Alternative methods
Attention!
Using alternative methods may cause the site to work incorrectly. If possible, try to change directory via control panel.index.php
If you want to place the site not in the root directory www, but, for example, in the directory www/dir, create a file index.php with this content:
<?php
require_once("dir/index.php");
Instead of dir/index.php, specify the path to your site's index file.
Place the created file in the root directory of the site and set permissions for it to 750.
Also be sure to set open_basedir to a level higher to access other directories on the site.
.htaccess
In some frameworks, the main site directory with the index file must necessarily be placed not in the root directory of the site, but in the public or web (or other) subdirectory.
To solve such a problem, you can create in the site root directory a file .htaccess with this content:
DirectoryIndex /public/index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) $1 [L]
RewriteCond %{DOCUMENT_ROOT}/public%{REQUEST_URI} -f
RewriteRule ^(.+) /public/$1 [L]
Another option:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/web/.*$
RewriteRule ^(.*)$ /web/$1 [QSA,L]
Yet another option:
RewriteEngine On
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]
Possible problems
Site errors that may be related to the root directory:
- 403 — check in the site root directory for the presence of an index file and in general the correct placement of site files.
- 404 — make sure that the path from the "Root directory" field actually exists.