[email protected] +91-120-6025102
Submit

Avail Best discounts

Please fill in the form below and we will contact you within 24 hours.

How do I make a sub directory or folder act as the public_html for your main domain?

The main domain of the hosting account uses the public_html directory for its Web site files. Add on domains use sub-directories inside the public_html directory. In order to setup your main domain for using a sub-directory on your hosting account, you will require to setup a re-direct in the .htaccess file located in the public_html folder so that the server understands that any request related to your main domain will be directed to a sub-directory on your public_html.

To setup the redirect /rewrite, edit the ~/public_html/.htaccess file. Insert the below given code block and mark modifications as noted in the (#) comments.
# Hostmonster.com
# .htaccess main domain to subdirectory redirect
# Copy paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
Rewrite Engine on:
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change this line.
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 yourdomain.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.)?yourmaindomain.com$
RewriteRule ^(/)?$ subdirectory/index.php [L]
Visitors on your Web site will not be able to tell that your main domain uses a sub-directory, they will still see the Web site address as: http://www.yourdomain.com/page.html.

Was this answer helpful? #4 #0
 

Related Questions

Submit Query

Please fill in the form below and we will contact you within 24 hours.