Your main domain will use the public_html directory for all of its website files by default. Addon domains use subdirectories inside the public_html directory.

 

In order to also set up your main domain to use a subdirectory on your hosting account, you will need to set up a redirect in the .htaccess file in the public_html folder so that the server knows that any request for your main domain will be redirected to a subdirectory on public_html.

 

Modifying the .htaccess

 

The following code will need to be added to the .htaccess file in the public_html folder of your hosting account. You will need to insert the following code block and make modifications as noted in the (#) comments.

 

You will need to change the two instances of example.com to your domain, and the three instances of the subdirectory to the folder where you want your site.

 

# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on 
# Change example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/subdirectory/ 
# Don't change the following two lines. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteRule ^(.*)$ /subdirectory/$1 
# Change example.com to be your main domain again. 
# Change 'subdirectory' to be the directory you will use for your main domain 
# followed by / then the main file for your site, index.php, index.html, etc. 
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteRule ^(/)?$ subdirectory/index.html [L]

 

Visitors to your website will not be able to tell that your main domain is using a subdirectory.

 

Note:  This method is not guaranteed to work with every script or software and can be used at your own discretion.

 

Was dit antwoord nuttig? 0 gebruikers vonden dit artikel nuttig (0 Stemmen)