问题
I would like to understand how to set up the following domains, websites and IP addresses for the following scenario:
User types www.mysite.com and this resolves to www.mysite.com which I can do without any problems to host A
On the site on host A, a user then clicks a link to retailers.mysite.com and this resolves to retailers.mysite.com on host B and all pages under this URL should point to this too.
How would I go about setting this up? Is it even doable?
The reason I want to do this is that I want to host a blog with one host (host A in the example above) and the core website with another host (host B in the example above) but I want it to look like one website (mysite.com)
回答1:
Yes this is easily accomplished via the dns settings for your domain.
You need to know the IPAddress or domain name for the different hosts. You can then setup a CNAME record for the subdomain and point it to the coresponding target host
i.e.
*.mysite.com -> A Record -> host A
retailers.mysite.com -> CNAME -> host B
回答2:
This is absolutely feasible. Subdomains (such as retailers.mysite.com) can resolve to a different IP address than the main site. In fact, I've used this feature before to make a subdomain of my website redirect to my PC's current IP address.
Whether this feature is available may, however, may depend on who the domain name's registrar is and what configuration options they provide. Some registrars may charge extra if you have more than a particular number of sub-domains, others allow unlimited numbers.
Another (alebeit inferior and slower) way to accomplish the same goal would be to use Mod Rewrite to rewrite urls so they go to the other server.
来源:https://stackoverflow.com/questions/7949758/can-i-set-up-websites-on-multiple-hosts-using-the-same-domain-name