Hosting Multiple Domains On Shared Host .htaccess

shauntir

Well-Known Member
Joined
Sep 11, 2013
Messages
457
Reaction score
0
Location
Durban
Hi

So I've decided to get into hosting some basic sites as an addon service. I'm more used to IIS than Apache.

I've have the following:

- Main domain registered on cPanel: myname.co.za
- Additional domain: additionaldomain.com

I've added additionaldomain.com as an addon domain in cPanel.

My root web directory has an .htaccess file and 2 sub-folders: myname.co.za and additionaldomain.com.

I've turned off indexing so it doesn't list the sites. I want to basically have (www.)myname.co.za and (www.)additionaldomain.com point to their respective sub-folders. I also want to ensure that this does not happen:

* myname.co.za/myname.co.za
* myname.co.za/additionaldomain.com

This is what I tried in the .htaccess file:

Code:
#Site 1
RewriteCond %{HTTP_HOST} ^myname.co.za$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.myname.co.za$
RewriteCond %{REQUEST_URI} !myname.co.za/
RewriteRule (.*) /myname.co.za/$1 [L]

#Site 2
Same as site 1 but with additionaldomain.com

I'm wanting these to be Wordpress sites so I've changed the permalinks accordingly.
 
Now I remember something, apache vhosts. I guess now the question is, is this supported on shared hosts.

If not, the above .htaccess solutions is needed.
 
In CPanel, if you added the addon domain, it gets it's own directory apart from your main site (which you can also change to have it's own directory BTW) and you can do wordpress installs on each, with separate htaccess files for each.

Since it looks like the sites are already in their own sub directories, you don't have to worry about the root directory with the htaccess. The host should automatically route abc.co.za to the abc.co.za directory and the xyz.co.za to xyz.co.za directory (you can check the path of the setup on the domain list in cpanel)
 
If you would like to give me a temporary login I can log in and check for you if you'd like
 
Why don't you just get your own Linux virtual server and then you can do whatever you want. They are so cheap these days that it's not even worth using shared hosting anymore.
 
So I did a little more digging and emailed my service provider.

The solution is to actually create an addon domain outside of the web root directory. So create it outside of the "www" or "public_html" directory.

So I put my main domain inside "public_html" and the addondomain.com in "websites/addondomain.com". Like so

Code:
./
	public_html/
		main domain files *
	websites/
		addondomain.com/
			addon domain files *

However, the other problem is that in cPanel the addon domain creates a mandatory sub-domain. Unfortunately, that is bad for SEO in some instances http://forums.cpanel.net/f5/subdoma...el-bad-search-engine-optimization-444261.html.

Have a few reasons that I haven't done my own VPS for client hosting (have a few I play around with for personal sites etc):
  • - Large time investment to maintain the server relative to the software dev I do. I.E, I make more money in dev than hosting. Lots of time is needed for health and monitoring, security updates etc.
  • - Easy enough to get the wife to help out in terms of installing wordpress on a shared server with cPanel etc
  • - No need to worry too much about email hosting as shared hosts provide these as well
  • - Cheaper than most VPS. With the provider I am using so I can offer customers cheaper hosting



However, with the restriction of cPanel creating sub-domains, I may just get an internationally hosted VPS. Probably setup a server with one of the free panels and use a local provider for email only.
 
Last edited:
Hi,

if you are referring to duplicate content for SEO, why not just create a 301 redirect rule that redirects the links to normal addon domain?

It is BAD for SEO and this is a solution for cPanel providers that I found:
http://nazgoz.blogspot.com/2013/05/301-redirect-subdomain-to-addon-domain.html

Also inform your Provider about this solution for future clients don't think many know about it. I've just informed our Writer to write up a article like the above link to assist our customers if they have this issue aswell.

Hope this helps
 
Hi,

if you are referring to duplicate content for SEO, why not just create a 301 redirect rule that redirects the links to normal addon domain?

It is BAD for SEO and this is a solution for cPanel providers that I found:
http://nazgoz.blogspot.com/2013/05/301-redirect-subdomain-to-addon-domain.html

Also inform your Provider about this solution for future clients don't think many know about it. I've just informed our Writer to write up a article like the above link to assist our customers if they have this issue aswell.

Hope this helps

Thanks for the assistance. You guys are actually my provider :) Really happy with your assistance and service.

I did add in a redirect but forgot the wildcard option. Still a little iffy about it but it's not too bad. The other option was to add in a fake domain as the main domain. That was from the link I posted.
 
Top
Sign up to the MyBroadband newsletter
X