How to change the document root in cPanel Print

  • 0

The document root is the folder a domain serves its website from.

Addon domains and subdomains

  1. In cPanel, open Domains.
  2. Click Manage beside the domain.
  3. Change the New Document Root and click Update.

Your main domain (public_html)

The main domain always uses public_html. To serve it from a subfolder (for example public_html/site), add this to public_html/.htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.co\.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/site/
RewriteRule ^(.*)$ /site/$1 [L]

Frameworks such as Laravel that need a public folder as the root can use the same approach. Test carefully after making changes.


Was this answer helpful?

« Back