View Full Version : Using .htaccess to host multiple sites on one host
Rapids
2nd December 2009, 12:26
Can anyone see a negative reason for using a .htaccess file to host two sites with one host?
I know it can be done without paying for a 'domain pack'.
stugster
2nd December 2009, 12:30
Sub domains? You wont be able to host multiple domains?
Rapids
2nd December 2009, 12:34
I want to avoid sub domains.
I believe there is a way to url rewrite so you actually have two different websites on a single host account... if you have access to the DNS information. So effectively two different directories are pointed to with two separate domains. I just wondered if there would be a negative factor somewhere, probably with the SEO if any.
webhostuk
2nd December 2009, 12:39
I dont feel this will really affect your sites SEO, you can surely do it.
NuBlue
2nd December 2009, 12:40
Or you could just pay the extra £3-10 per month for some more hosting and save the hassle..... just a thought!
Rapids
2nd December 2009, 12:57
Thanks for the replies. I will give it a go. In the meantime, if anyone does know of any reasons not to do it, I would gladly know.
I could pay the extra amount per month, but I might enjoy the hassle!
Astaroth
2nd December 2009, 14:54
Not up on Apache and therefore the .htaccess but if I am guessing correctly on what your intending to do (use a domain alias so both domains point to the same directory and then use .htaccess to rewrite to separate documents) then the only limitations are on any back end access (eg email, ftp etc) will be shared across the two domains.
These are probably not an issue if you intend to run the sites yourself and wont have anyone else that you want to work on one domain but not the other.
awebapart.com
2nd December 2009, 14:57
two different websites on a single host account
It is an interesting idea.
Can anyone see a negative reason for using a .htaccess file to host two sites with one host?
Here are a few negative reasons I can think of:
1. It limits your choice of hosting company to only those that allow multiple domains per hosting account
2. You may also have to check your hosting company's T&Cs about intended use, whether you can resell (or sub-let) on a non resell account (if the sites are not all for you), some hosts may have other terms like the domains have to be registered with the host, or other 'fair use' policies
3. You might need to ask yourself if the host allows this kind of thing on their shared server, then how open to abuse is this? What kind of other clients would exploit this with what kind of other websites on the same server? How would those other websites affect your websites? e.g. SEO-wise or spam-wise being on the same IP address neighbourhood. How strained might the server be with the possibility of thousands of domains on the same server? etc
4. You are sharing the bandwidth and other limits for the overall hosting account between the sites. Also if each website required its own database, but the account only provided one database then there would be issues.
5. Your hosting account web stats might be a bit confusing, e.g. trying to easily see bandwidth used for each site, and 404 error handling and logging might be an issue or confusing too
6. You need technical skills in .htaccess and url rewriting to do this, and generally extra coding may be required in other areas too.
7. You will probably have to rewrite file accesses too, not just page access, in order to keep the websites completely separate, i.e. jpg, css, js files via rewrite and this will add some overhead
8. If you require different other .htaccess settings in the same root directory for different sites, then you might have problems with this
9. Emails sent from the websites might only be sent from the primary hosting account domain
10. Security exploits, if hackers get into hosting account level access via one website, then they might be able mess up all of your sites
I have only focused on the negatives here (since that's what you asked for), but I do think it is an interesting idea, and it could work for simple websites.
sysconfig
2nd December 2009, 15:30
You need to use the <VirtualHost> directives, because otherwise the Apache won't know how to answer requests for the second domain.
Unfortunately, <VirtualHost> can't be used in .htaccess. It's only available in the main server configuration context, which you don't have access to in a shared hosting environment.
Your approach would only work, if your current domain was the only one on the server, and if it was actually using Apache's default context (default = target for all domains not specified in a dedicated VirtualHost context). If you are using shared hosting, this (hopefully) isn't the case.
awebapart.com
2nd December 2009, 17:36
You need to use the <VirtualHost> directives, because otherwise the Apache won't know how to answer requests for the second domain.
Unfortunately, <VirtualHost> can't be used in .htaccess. It's only available in the main server configuration context, which you don't have access to in a shared hosting environment.
This will already be taken care of by the control panel of the hosting companies that provide multi-domain hosting in the one shared hosting account. i.e. The account owner adds a domain alias in the control panel, and the control panel software makes the necessary underlying virtualhost config changes.
That then leaves the account owner to implement how multi-domains are handled in .htaccess. The host would have to provide apache mod rewrite functionality to make things easier and more flexible, not all hosts provide this.
sysconfig
2nd December 2009, 17:51
If he could just add another domain in his control panel, would we have this discussion then? :D Maybe a misunderstanding on my end. :p
awebapart.com
2nd December 2009, 18:11
If he could just add another domain in his control panel, would we have this discussion then? :D Maybe a misunderstanding on my end. :p
My understanding is that the OP is looking into a single hosting account that provides multiple domains, e.g. different domains pointing at the same web hosting space (same hosting account). But the OP is then looking into how he can get different websites to appear for each domain, within the one same hosting account (e.g. the different websites which are physically in different folders). Like this (http://www.webmasterworld.com/apache/3081740.htm).
Rapids
3rd December 2009, 14:26
Well, I think it's done. I don't suppose it was too difficult either.
Thank you all for the replies!