🌼 Spring Sale — Up to 60% discount for hosting and domains
Frequently Asked QuestionsDev

How can I host my main domain from a sub-folder using the .htaccess file?

In this article, we will explain how to host the main domain in a sub-folder using the .htaccess file.

Views 755Updated 6 aniPublished on 26/06/2019by Alexandru Jurca

By default, the main domain will use the public_html directory for its files.
Additional domains (addon, subdomains) will use subdirectories within the root directory.

However, it is possible to host the main domain from a subfolder within public_html by setting up a redirect in the .htaccess file in the public_html folder, so that the server redirects all requests for the main domain to the respective subfolder within public_html.

Website visitors will not know that the domain is loading from a subfolder, as this will not be added to the URL name.

To perform this operation, the following lines will need to be added in the file.htaccess, from public_html:

#Activate Rewrite mode
RewriteEngine on

#Replace "domeniu.ro" with the desired domain
RewriteCond %{HTTP_HOST} ^(www.)?domeniu.ro$

#Replace "subfolder" with the name of the subfolder used.
RewriteCond %{REQUEST_URI} !^/subfolder/

#Do not change these lines
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#Replace "subfolder" with the name of the subfolder used.
RewriteRule ^(.*)$ /subfolder/$1

#Replace "domeniu.ro" with the desired domain
RewriteCond %{HTTP_HOST} ^(www.)?domeniu.ro$

#Replace "subfolder" with the name of the subfolder used and index.html with the desired default page.
RewriteRule ^(/)?$ subfolder/index.html [L]

Similar Articles

Can the main hosting domain be changed?Frequently Asked Questions /Random

If for various reasons you no longer want a domain to be listed as the primary on hosting, then you will need a change.

3
by Sebastian Szlivka
Views 1365
Updated 1 year ago
Published on 23/07/2018
What is Shopify?Frequently Asked Questions /DNS

Discover how to configure the domain for your Shopify store using Hostico services. Benefit from technical support and a configurable DNS zone for quick and secure integration.

3
by Mark Dohi
Views 636
Published on 06/02/2025
What is Wix?Frequently Asked Questions /DNS

Discover how to quickly connect your domain to the site created with Wix using Hostico's services. You have access to a fully manageable DNS zone and dedicated technical support for a simple and efficient setup.

by Mark Dohi
Views 340
Published on 01/07/2025
by Mark Dohi
Views 314
Published on 21/08/2025