Knowledgebase

KnowledgebaseCloud/VPSCloud HostingFile Management
Back to File Management

Can I Point My Primary Domain To A Sub-folder


This article is for WestHost cPanel Accounts. Determine which control panel your account uses with this guide.


It is possible to point your primary domain to a sub-folder within public_html rather than public_html itself. While WestHost Support cannot make this change for you, here is some information that should allow you to do so yourself.


To set up your main domain to use a sub-folder on your hosting account, you will need to set up a redirect in the .htaccess file in the public_html folder. This is so the server knows that any request for your main domain will be redirected to a sub-folder on public_html. Visitors to your website will not be able to tell that your main domain is using a sub-folder. They will see the website address as http://www.yourdomain.com/page.html. You can add the following code to your .htaccess file:



# .htaccess main domain to subfolder redirect
# Copy and 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.
RewriteEngine on
  
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
  
# Change 'subfolder' to the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subfolder/
  
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
  
# Change 'subfolder' to the folder you will use for your main domain.
RewriteRule ^(.*)$ /subfolder/$1
  
# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder 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 ^(/)?$ subfolder/index.php [L]





Related Articles

Am I Responsible For Monitoring My Bandwidth Usage
Can I Add My Own CGI Scripts
Can I Reset My Website Files
Can I Use A .htpasswd File In My Account
Can I Use cPanel In The Safari Browser

Can’t Find what you need?

No worries, Our experts are here to help.