Subdomain routing

SO i have Multi Module Apllication ,and i want to create a subdomain for my api : api.mydomainname.com and NOT use mydomainname.com/api , how can i achive this ? i am running on Apache , ubuntu 14.04.

The concept :

Make a request to api.mydomainname.com

Pass some params , examples :

api.mydomainname.com/createaccount

api.mydomainname.com/fetchaccount -> Method _POST with Values