3

I am trying to configure a wildcard subdomain that will redirect all the subdomains to my main domain.

subdomain.newbuildhomesaz.com -> newbuildhomesaz.com

I created the wildcard subdomain *.newbuildhomesaz.com in the cPanel. I checked the DNS configuration and the A Record was created and it looks fine.

I then edited the .htaccess file with the following

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.+)\.newbuildhomesaz\.com$ [NC]
RewriteRule (.*) http://newbuildhomesaz.com/$1 [L,R=301,QSA]

I can access the main domain newbuildhomesaz.com

However when I try to access a random subdomain like abc.newbuildhomesaz.com I get an error message:

This site can’t be reached

abc.newbuildhomesaz.com’s server DNS address could not be found.

ERR_NAME_NOT_RESOLVED

I have been on the phone with Hostgator throughout the day and they don't seem to be able to help me.

I am on a shared hosting plan with them.

  • As of 2017.03.15-01:54 UTC nslookup abc.newbuildhomesaz.com NS8331.HOSTGATOR.COM still reports ** server can't find abc.newbuildhomesaz.com: NXDOMAIN. That's on their DNS, not from propagation. – user686699 Mar 15 '17 at 1:56
2

If newbuildhomesaz.com. is your domain, the DNS A record for wildcard subdomains, *.newbuildhomesaz.com. is not properly configured. No A record is returned:

root@node51 [~]# dig '*.newbuildhomesaz.com'

; <<>> DiG 9.10.3-P4-Ubuntu <<>> *.newbuildhomesaz.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 57822
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;*.newbuildhomesaz.com.         IN      A

;; AUTHORITY SECTION:
newbuildhomesaz.com.    1799    IN      SOA     ns8331.hostgator.com. root.gator4166.hostgator.com. 2016020100 86400 7200 3600000 86400

;; Query time: 44 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Tue Mar 14 20:23:45 CDT 2017
;; MSG SIZE  rcvd: 118

If you are certain that there is an A record for *.newbuildhomesaz.com. in cPanel, something has gone wrong on the server that prevented the zone record from being created.

You can verify this by opening a ticket with HostGator, explain the situation, then ask them to run the command grep '^*' /var/named/newbuildhomesaz.com.db. The command should return a line that looks like this:

*       14400   IN      A       108.167.133.22

If there is no such line, the A record was not created.

If that line exists, the BIND DNS configuration has not loaded the new configuration. The support administrator should run named-checkzone 'newbuildhomesaz.com' '/var/named/newbuildhomesaz.com.db' and check that the last line reads "OK". If there is an error, your domain's zone file is broken.

If there is no error, the BIND DNS server needs to be reloaded with rndc reload. The support administrator can then verify that the wildcard subdomain works with dig '*.newbuildhomesaz.com' A @gator4166.hostgator.com.

If the wildcard subdomain still does not show an A record, there is something else wrong with the DNS configuration on the server that will require deeper investigation.

Note: Since you are a tenant on shared hosting, you cannot make changes to your zone file /var/named/newbuildhomesaz.com.db or to the DNS server yourself. A support administrator with root access will need to do this; phone and chat support cannot do this.


Additional Resources

  • Thank you for taking the time to help me with my issue. I have just spent 1h30min with hostgator support. In the end they said that the A Record was created correctly, but because it is an A record we should wait between 4 and 8 hours for it to propagate. I am at the 5 hour mark. I told them I would wait for the 8 hours and try again. I didn't know subdomains had to propagate. I thought the DNS servers would know to send all the subdomains to Hostgator. – jdias Mar 15 '17 at 1:46
  • dig '*.newbuildhomesaz.com' A @gator4166.hostgator.com asks the server itself for the wildcard. There is no A record returned. Since the DNS server itself doesn't know about your wildcard domain, this is not a propagation issue. – Deltik Mar 15 '17 at 2:04
  • thank you. That makes sense. I am opening a chat with Hostgator to see if they can finally resolve my issue. I do see the A Record in cPanel. – jdias Mar 15 '17 at 4:19
  • Question - in my cPanel I see the following entry .newbuildhomesaz.com. 14400 IN A 108.167.140.95. Should it be '.newbuildhomesaz.com' or just ''? In your response it shows only the ''. Thanks. – jdias Mar 15 '17 at 4:30
  • @jdias: They are equivalent. * and *.newbuildhomesaz.com. mean the same thing for your purposes. – Deltik Mar 15 '17 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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