cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New

How to map main domain to serve website from a separate folder on host?

Hey guys,

 

I have 2 domain sit on my hosting. One of them is my main domain attached to the hosting account. Another one is addad as addon domain and a new folder is created and a wordpress site installed within that folder.

The other one (the main domain) can not be added as addon but I want to set up a wp on that domain as well so I need to create a separate folder within the publi_html to get a new WP installation inside that folder 

So how can I use 2 domains as websites on the same hosting account if one of them is my main domain attached to the hosting account?

 

Thanks

1 REPLY 1
Helper V
Helper V

Re: How to map main domain to serve website from a separate folder on host?

.htaccess file will allow you to install wordpress in a sub folder but have main domain pointing to the sub folder.

Here is a link from Bluehost on how to do just that. The code I provided will need to be modified to your domain and sub folder. 

How to host the Primary Domain from a subfolder (.htaccess)

# .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]

adding this to htaccess file will allow your primary domain to be accessed from a subfolder.

You will need to install wordpress to the sub folder and then add the htaccess file.