2.4.1.1.2. Site root directory

Standard paths to the root directories of sites look like this:

  • For a site on the main domain: example.com/www.
  • For a site on a subdomain: example.com/subdomain.

Important points:

  • You can only specify one of the subdirectories. Directories outside of the root directory cannot be specified.
  • To point multiple domains to one site, use aliases.
  1. Openup site settings.
  2. Specify the name of the subdirectory in the field «Root directory» and save the changes:
  3. Wait a few minutes for the changes to take effect.

Attention!

The use of alternative methods may lead to incorrect operation of the site. Try as much as possible change directory through the control panel.

If you need to host the site not in the root directory www, and, for example, in the directory www/ru, create a file index.php with the following content:

<?php
require_once("ru/index.php");

Where ru/index.php Is the path to your site's index file.

Place the created file in the directory www and install right for him 750.

Also, be sure to set the parameter value open_basedir one level up to access other site directories.

In some frameworks it is required that the main directory of the site where the index file is located is different from www... For example, Zend Framework — this requires an explicit indication of the main directory of the site public... You can work around this by creating in the root directory of the site (www) file .htaccess with content like this:

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]

And further:

RewriteEngine on
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]

Errors when opening the site, which may be related to the root directory:

  • If an error occurs 403, check that the index file is in the root directory and that the site files are located correctly.
  • If an error occurs 404, make sure the path specified in the field «Root directory», exists on the hosting.
Content