I want to create a subdomain in Hostgator and to do it I go in cpanel to subdomains and give the name I want and leave the root directory to default value but when its created its only available trough www.example.com/sub, what I want is to have trough sub.example.com.

  • Have you added the sub-domain using your DNS? You will likely do this with your registrar. You would create a CNAME to map your sub.example.com to example.com. It may take time for DNS to propagate, however, most of the time, it will be available immediately. From there, your web server should recognize the request and serve the sub-domain from the /sub directory. Many hosts use this configuration, however, I do not like this. You can change the directory of the sub-domain to someplace else by editing the configuration if you care. Otherwise, this should be all you need. Cheers!!
    – closetnoc
    Commented Dec 5, 2016 at 0:11
  • Who controls your master DNS records? Hostgator or your domain registrar (if different)?
    – MrWhite
    Commented Dec 5, 2016 at 11:07
  • thanks for your reply guys ,,, i'm using hostgator as my host and registrar ,, so please can you tell me how to use the cname cause i never used it before and do not know how to configure it properlly ,,, i will also use it to redirect 'www.example.com' to 'example.com'
    – dantosso
    Commented Dec 5, 2016 at 17:55
  • There are tutorials on the HostGator web site on how to do this. They also have their own forum.
    – Rob
    Commented Jan 10, 2017 at 15:44

1 Answer 1


If you're using HostGator, login into your Cpanel and go this section enter image description here

  1. As you can see, there is an option to add a subdomain.
  2. Click on it and you shall be taken to a screen wherein you can enter the subdomain you want and it will auto-populate it with a folder.
  3. Change or Create the folder and keep the files you want there
  4. Make the final entry and you should be good to go

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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