Forum Moderators: phranque

Message Too Old, No Replies

running multiple domains on the same host

         

iforgotyourfirstname

9:40 pm on Jul 30, 2015 (gmt 0)

10+ Year Member



I am trying to figure out how to structure this.
I have bought new hosting. I will have 5 domains with this host. The addon domains will be folders in root. some sites will be wordpress based, others will be pure html/css based. All sites will have their own htaccess. I want to structure this so that the htaccesses fro different domains don't interfere with each other.

I know nothing about htaccess but from my research, I understand this is what I need to do:

1) create htaccess in root, and put this code in there, where example.com is my main domain that I used to register with the host.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ henry [L]


2) create a folder in root named henry
3) upload all wordpress installation files to henry folder
4) create mysql databse in host
5) go to example.com/henry and begin installing wordpress as usual
6) go to example.com/henry/wp-admin and log in
7) install theme, etc.
Now main domain should work as normal.
8) for the addon domains, just go to hosting control panel, create the addon domains, host will automatically create folders for the addon domains, upload the files to the automatically created folders via FTP.

do you see any problems with this set up?

lucy24

1:22 am on Jul 31, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



do you see any problems with this set up?

Let's backtrack.

The first thing you need to sort out is the physical file structure. When you say "addon" this implies that things go like this:
/pathblahblah/firsthost/
/pathblahblah/firsthost/secondhost/
/pathblahblah/firsthost/thirdhost/
et cetera, so things are inherently asymmetrical. If you're setting up new hosting, the smartest thing you can do is designate some dummy domain name to be your "primary" (/firsthost/ in this scenario), and don't really use it for anything. That way, requests for one domain never have to pass through an htaccess file belonging to a different domain. In effect, your "primary" has become the equivalent of a "userspace": an area shared by all domains.

This, in turn, means that you don't need to have a
RewriteCond %{HTTP_HOST} blahblah
attached to every single RewriteRule in the primary htaccess-- because this htaccess file simply won't contain any RewriteRules. You can use it for other stuff like Allow/Deny directives, where normally you'd want all sites to share the same rules.

RewriteCond %{HTTP_HOST} ^(www.)?example.com$
This is a far-from-optimal wording. Just say, without anchors,"example.com". (Rare exception if you've got domains with overlapping names, or possibly subdomains based in different but parallel directories.) Incidentally, you should escape \. all periods, though in this specific context it's a non-critical error.
RewriteRule ^(/)?$ henry [L]
ALWAYS start the target of a RewriteRule with either a /slash (meaning "document root") or full protocol-plus-domain (when you're creating a redirect). Then you don't even need to think about a RewriteBase.