问题原文
原帖链接 · Jaron Gao · CC BY-SA 3.0
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:
*points tocompany.com.(Everything goes to production)*.stagingpoints tosomething.herokuapp.com.stagingalso points tosomething.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.
已采纳解答
原帖链接 · jcaron · CC BY-SA 3.0
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.
DNS points the domain to the right server:
check using
dig(ordrill),nslookupor even simplypingortraceroute. 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.netwhich will give you a much more detailed view of how the whole process goes.
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-voption) to see what happens when you connect to the URL (is there a redirect — or several?)check
.htaccessfiles forRedirect*andRewriteRuledirectives which may cause the redirectthere may be further redirects generated in code, but then we would need a lot more details about what software you are running.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
