Jump to content

CNAME question


sb13

Recommended Posts

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

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.