views:

24

answers:

1

Hi,

I own the a domain like "www.example.com". How do I setup ownership over "api.example.com"?

And I have all my files hosted on a php server (at a hosting provider) and when I login to the file system I can see stuff like:

 /index.php
 /help/index.php

etc.

How do I map stuff like: api.example.com/v1/getAnimalNames.php

to a file in my file system?

Thanks

+1  A: 

Presumably, your domain is "mysite.com" and not "www.mysite.com" .

As owner of that domain, you own every possible sub-domain. Your hosting provider probably set up a subdomain "www" for you to hang your Web server off. People are kind of used to seeing Web sites having a "www" subdomain.

To control subdomains, you need to control the name servers that give out your domain information to the Web. The name server configuration file gets a little stanza (a so-called "A record") for every subdomain you want to officially support. The bonus is that you can route each sub-domain to a specific server, i.e. host computer.

If the root of your domain is already configured to point at your main (and perhaps only) server, (you can test this using NSLOOKUP with the bare domain name), then there's a simpler alternative. If your Web server is Apache, you can define virtual servers for subdomains in Apache's configuration, and everything sort of works. Reverse name resolution isn't fully clean but close enough for most purposes.

Carl Smotricz