Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

How can I forward a 'non-existant' subdomain to a 'physical' subdomain?

I.e.: api.website.com -> api.company.com

Where the first is just a CNAME pointer and the last is a real subdomain with a root.

At website.com I have:

api CNAME api.company.com.

At company.com I have:

api.website.com CNAME api.company.com (also tried this with just API)
api.company.com A 1.2.3.4
share|improve this question

1 Answer 1

up vote 1 down vote accepted

It appears that you want to create a subdomain to a root IP address, and then forward a subdomain from a different domain to this subdomain.

First you would create an A record for the api.company.com subdomain as demonstrated here under "Example 1" (ignoring the FTP part; also note that www is considered a subdomain as well, just like api).

So in the DNS tables for company.com you'd create an A record for:

api.company.com A 1.2.3.4

This establishes an alias record for host api.company.com at IP address 1.2.3.4

Next you'd create a CNAME to this external host as demonstrated here under "Example 3". So in the DNS tables for website.com you'd create a CNAME record for:

api CNAME api.company.com.

This points api.website.com -> api.company.com

Then you'd need to wait 24-48 hours for these DNS changes to propagate to DNS servers throughout the Internet in order for these subdomains to resolve properly, so don't make any other changes during that time.

share|improve this answer
    
The first part is already there, because I created a legit subdomain for api.company.com. I had already added the CNAME record on website.com, so I guess I still have to wait for the changes to propogate? The weird part is.. when I go to api.website.com, it's white for a considerate amount of time before Chrome throws an error.. –  Gerben Jacobs Jul 9 '13 at 17:08
    
As indicated in your question, you didn't need to create a CNAME on company.com for api.website.com since that host should be managed in the DNS for the website.com domain. Also, this question and my answer are only addressing the DNS setup - you'll still have to make sure api.company.com is serving the content correctly, which api.website.com will also serve. Yes, you'll have to wait for the DNS to propagate once everything is setup correctly. –  dan Jul 9 '13 at 19:52
    
Nah, it doesn't work. You suggested: CNAME at original server and A at new server. I've done those both. But it seems like the new server should somehow know that it can accept the first domain, right? –  Gerben Jacobs Jul 12 '13 at 7:55
    
That isn't necessary since you can forward a subdomain to any other subdomain, as demonstrated in the example links. However, as I wrote in my comment above, you'll have to do some configurations in your server to make sure the api.company.com subdomain is serving the content, and also not preventing api.website.com as a host. –  dan Jul 12 '13 at 8:03
    
BTW, is it necessary to have api.website.com -> api.company.com or can you just have api.website.com -> 1.2.3.4 since that's what api.company.com is pointed to anyway? In that case, you can just create an A record in the DNS for website.com for: api.website.com A 1.2.3.4 –  dan Jul 12 '13 at 8:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.