Article Background
Back to Knowledgebase

How to Change the Document Root for Your Website in DirectAdmin

Web
Cubes Support
July 20, 2026

By default on DirectAdmin, your domain's public web root is located at:

/domains/yourdomain.com/public_html

However, modern PHP frameworks (such as Laravel, Symfony, Statamic, or custom Web applications) store their public entry file inside a subfolder like public_html/public/ or public_html/web/. Pointing your server's Document Root to this subfolder is essential for application security, ensuring that private files (like your .env configuration file, database credentials, and vendor/ packages) cannot be accessed directly by web browsers.

This guide will show you how to change your website's document root in DirectAdmin.


DirectAdmin allows you to customize the public document root path for your domains directly from the control panel interface.

  1. Log in to your Cubes Hosting DirectAdmin Control Panel.
  2. Navigate to Account Manager > Domain Setup.
  3. Click on your domain name.
  4. Look for the Document Root (or Private HTML / Web Root) option.
  5. Change the target directory from public_html to your framework's public subfolder:
    public_html/public
    
  6. Click Save (or Modify).

DirectAdmin will update your Apache/Nginx web server configuration automatically, and your domain will now serve files directly from /public_html/public/.


Method 2: Using .htaccess Rewrite (Alternative Method)

If you prefer not to change global domain settings or are running multiple sub-applications:

  1. Open your DirectAdmin File Manager and navigate to your main /public_html/ folder.
  2. Create or edit the .htaccess file inside /public_html/.
  3. Add the following mod_rewrite code to redirect incoming web requests into your /public/ subfolder:
<IfModule mod_rewrite.c>
  RewriteEngine On

  # Redirect requests to the /public/ directory
  RewriteCond %{REQUEST_URI} !^/public/
  RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
  1. Save the .htaccess file.

For developers using Git deployments or CI/CD pipelines:

  1. Connect to your web server via SSH Terminal.
  2. Navigate to your domain directory:
    cd ~/domains/yourdomain.com/
    
  3. Backup or remove the existing empty public_html directory:
    mv public_html public_html_backup
    
  4. Create a symbolic link pointing public_html to your framework's public folder:
    ln -s /home/username/domains/yourdomain.com/my-laravel-app/public public_html
    

Security Verification

After updating your document root, verify that your private configuration files are inaccessible from the web:

  1. Open a browser and attempt to visit: http://yourdomain.com/.env
  2. You should receive a 404 Not Found or 403 Forbidden error. If the file downloads or displays text, your document root is still pointing to the main directory!

Conclusion

Changing your document root is a fundamental security step for hosting modern PHP frameworks like Laravel or Symfony. Update your document root via Domain Setup in DirectAdmin or via .htaccess, and keep your core application files protected!

Special Offer

Ready to Start Your Server?

Get 10% OFF your first month on any server with promo code CUBES10 at checkout!

24/7 Assistance

Need Help With Your Server?

Already a Cubes Hosting customer and couldn't find your answer? Our dedicated support team is available 24/7.