I want to create wildcard sub domains and all should point the same main domain's directory. And I read some articles and made this,


Now, if I type any sub domain it shows pageok. Now, how to make all the sub domains to point the same main domain. ?

  • 1
    Note that from an SEO perspective you may not want this. It can lead to lots of duplicate content, which generally isn't what you want. For most cases/users just setting the root & www. subdomain should suffice. Dec 9, 2015 at 17:24
  • Thanks for the informations. I can understand it. Even though I need to point all the wildcard domain to a same directory. Which may be some other directory. What you said is right. I agree with you. But I want all the wildcard domains to point a same directory.
    – Kvvaradha
    Dec 9, 2015 at 17:30
  • Any solution for this problem?
    – Kvvaradha
    Dec 14, 2015 at 12:51

2 Answers 2


Using the DNS records below, both the root domain and all subdomains will resolve to

example.com. 1800 IN A
*.example.com. 1800 IN CNAME www
www.example.com. 1800 IN CNAME example.com.
  • That points all the domains to the same server, but it doesn't address is question about the directory on the server. Dec 9, 2015 at 15:57
  • Since the question shows that the web server is configured to respond with 'pageok', the directory seems to have been configured. This DNS config will show that page for any sub/domain. But yes it is a little unclear. Dec 9, 2015 at 16:04
  • Actually mine hosting is shared one. So the domain I am saying is pointing a directory in hosting. Which actually requires to use the same for all of its sub domains.
    – Kvvaradha
    Dec 9, 2015 at 17:10
  • @Rodrigo, please explain me the steps to do. I am not much experienced in A record and Cname works.
    – Kvvaradha
    Dec 9, 2015 at 17:21
  • 1
    Please send those records to your hosting/DNS service provider. They can assist you further. Each provider has different steps, but the DNS records are in the correct syntax. Dec 9, 2015 at 18:21

You need to set the ServerAlias in the configuration file. I am guessing you have CPanel. Maybe you can search the docs for ServerAlias. Sorry I don't use CPanel.

ServerAlias *.mydomain.com

I use this all the time for testing and live hosting. My PHP code handles the sub domain content.

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.