We are trying to point a heroku staging app (something.herokuapp.com) to a subdomain on our domain (staging.company.com).

Everything else on the domain (*.company.com) goes to our previous production app.

I'm having trouble pointing subdomains of the subdomain to the heroku staging app. For example, login.staging.company.com should point to staging's login portal, and hospital.staging.company.com should load our app with the Hospital client's data.

I have 3 relevant CNAME records:

  1. * points to company.com. (Everything goes to production)
  2. *.staging points to something.herokuapp.com.
  3. staging also points to something.herokuapp.com.

Current behavior is that login.staging.company.com goes to app.company.com, thus it goes to our production app instead of our heroku staging app. However, login.staging.company.com/users/sign_in goes to our staging app just fine, but it is the ONLY link that is going to our staging app.

Which records do I need to add/remove to make sure that everything under *.staging.company.com goes to our heroku staging app, and everything not under that continues to go to our production app?

Ex. hospital.staging.company.com should go to staging, while government.company.com should go to production.

  • Have you 1) allowed for DNS propagation, or 2) done a 'dig' directly from the root servers (or the defined nameservers) to confirm that it will eventually work across the Internet? Do you do your own DNS or use a third party to do so?
    – user3919
    Commented Jan 18, 2016 at 1:34
  • The DNS has fully propagated. I've waited a whole day. I've also tested with another domain that redirects ALL subdomains to the heroku app. I'm not sure what dig is. We used digitalocean to manage our domain.
    – Jaron Gao
    Commented Jan 18, 2016 at 2:29
  • Use something like dns.squish.net to see how the root servers are delegating your domains.
    – user3919
    Commented Jan 18, 2016 at 4:03
  • Thank you. I used dns.squish.net to check login.staging.company.com, and it does indeed point to heroku, but upon visiting the link, it still reroutes to the production login portal (changes from login.staging.company.com to app.company.com.
    – Jaron Gao
    Commented Jan 18, 2016 at 16:31
  • OK, that sounds like you have an HTTP redirect in place, which means it's not a DNS issue at all. If you're willing to share the name of the actual domain, I can give you more details. If not, you might try a tool like "curl" to see what's going on.
    – user3919
    Commented Jan 18, 2016 at 16:34

1 Answer 1


Domain hosting has two parts:

  • the DNS must point the domain to a server
  • and the server must recognise the domain

You should verify both.

  1. DNS points the domain to the right server:

    • check using dig (or drill), nslookup or even simply ping or traceroute. All will take a domain name and let you know what the final resolved IP is. Check that it matches what you expect it to be.

    • or you can use online tools like dns.squish.net which will give you a much more detailed view of how the whole process goes.

  2. Server recognises the domain

This is specific to protocols which include the domain in the request (such as HTTP/HTTPS), and is of course vital for virtual hosting (hosting multiple domains on the same server with the same IP). This is something that is configured on the server.

The server must thus recognise all domains you are pointing to it (if you just point a domain to a server using DNS, and the server does not know about it, it'll have a hard time knowing what it should return). Depending on your hosting situation, this may be more or less complex to handle. Also, managing wildcard domains may add another hurdle, depending on whether you actually configure individual sub-domains on the host, or (try to) have it recognise a wildcard as well (not all servers/hosts can).

Once the request gets to the right virtual server, then you may have additional issues with local scripts, .htaccess files, Rewrite Rules, and more, which may not be properly configured and redirect somewhere else.

  • start by using a tool such as curl (with the -v option) to see what happens when you connect to the URL (is there a redirect — or several?)

  • check .htaccess files for Redirect* and RewriteRule directives which may cause the redirect

  • there may be further redirects generated in code, but then we would need a lot more details about what software you are running.

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.