sb13 Posted July 27, 2011 Share Posted July 27, 2011 Hey guys, First of all, I apologize if I wrote this in the wrong category. I realize that most of what is posted here is IRL stuff, but I did not find a suitable category. I have developed a website which is supposed to display different content depending on which URL the user is viewing the page from. Basically, if a user visits the website from www.somedomain.com, this domain name is matched with a profile in a database and the page is styled according to stored preferences. However, if a user visits from www.anotherdomain.com, the styling may be loaded from a different profile. So I am checking the domain to find out which styling to show. I am using $_SERVER['HTTP_HOST'] in PHP to find the domain name. When I initially started working on this site I thought that this concept could easily be accomplished with the pointing domains adding a CNAME record to my site. That is, www.somedomain.com and www.anotherdomain.com would both have a CNAME record pointing to www.mysitesdomain.com. In my mind that would display their domain in the browser but load my website. Is this true? The reason I am asking is because my hosting provider told me that this is not impossible without attaching the domains to my hosting, which I would prefer not to do. As far as I understand, a DNS query is restarted when a CNAME record is encountered, but the URL in the address bar will remain the same. Is this correct? I hope you guys understand what I mean and that I have explained it well enough. Thank you very much in advance, Andy Quote Link to comment https://forums.phpfreaks.com/topic/242953-cname-question/ Share on other sites More sharing options...
sb13 Posted July 31, 2011 Author Share Posted July 31, 2011 Bump. Quote Link to comment https://forums.phpfreaks.com/topic/242953-cname-question/#findComment-1249919 Share on other sites More sharing options...
gizmola Posted July 31, 2011 Share Posted July 31, 2011 No you can't reference another domain in a domain zone file using CNAME. CNAME lets you point to an ANAME for the same domain. However there is no problem having multiple domains point to the same IP. Every shared host in the world is doing this, using apache and the httpd 'HOST" header, which is what shows up in the HTTP_HOST. The key here is that apache must know to handle the domain. It looks at that same header and attempts to match it up with a vhost. This can be done, but you need to to have apache configured so that it will serve vhost content for that domain. I think this is what the hosting company is trying to tell you. YES you can serve the same vhost for multiple domain names, but you have to tell apache to do so. Quote Link to comment https://forums.phpfreaks.com/topic/242953-cname-question/#findComment-1249940 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.