If your website is in a subfolder (for example public_html/blogs) but should open at the domain address without /blogs, you can do this with an .htaccess rule in the main public_html folder.

The rule

Add these lines at the beginning of the .htaccess file in the public_html folder. Replace jusudomens.lv with your domain and blogs with the name of your folder.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?jusudomens\.lv$ [NC]
RewriteCond %{REQUEST_URI} !^/blogs/
RewriteCond %{REQUEST_URI} !^/\.well-known/
RewriteRule ^(.*)$ /blogs/$1 [L]

  • Save a copy of .htaccess before editing (see the article “File Manager – uploading, editing and deleting files”). The .well-known line ensures that the free SSL certificate can still renew automatically.
  • If the subfolder contains WordPress, the “Site Address (URL)” field in its settings (“Settings” → “General”) must contain the address without /blogs.
  • For an addon domain or subdomain, it is easier to change the folder: in cPanel, “Domains” → “Manage” → “New Document Root”.
  • If you need to send the visitor to another address (changing the address in the browser), use a redirect (see the article “Domain redirect (Redirects)”).
  • Laravel, Symfony and similar frameworks keep their publicly accessible files in a folder named public. In both lines of the rule that contain blogs, enter the path to this folder instead, for example laravel/public. Then check that jusudomens.lv/laravel/.env shows a 404 error – the .env file contains passwords, so it must not be reachable from the internet.

If you run into any difficulties, just write to us and we will help. support@area.lv

Was this answer helpful? 0 Users Found This Useful (1 Votes)