问题
I am aware that there have been a few discussions on this one but none have given a definitive answer. I am hoping this will help me and others.
Problem:
I have a domain name (www.xyz.com) registered with 1&1.
I want users to be able to type this in and be shown my website. A Heroku web app.
I want the domain name (www.xyz.com) to be displayed. Not any subdomain url or the heroku app URL.
I do not want the set-up do be anything that will have a detrimental impact on SEO.
Note:
I have just got off the phone with 1&1 and they have said that my only options are to do a frame redirect or a http forward. Neither of these meet the above requirements.
Additionally, other posts have suggested finding out what the Heroku IP address is and using this but Heroku recommend against this as they might change it without notice.
Please could I ask that any one kind enough to respond spells things out a little. Anyone having problems with redirects is likely to be new to this.
Thanks.
回答1:
never used the 1&1 services, but solving your problem is pretty straightforward.
Take the following steps:
- Add you domain to heroku.
heroku domains:add www.xyz.com
. If you have more than 1 app in your heroku account, remember to pass the--app
flag - Now you should have something like
myherokuapp.herokuapp.com
where myherokuapp is the name of your app on heroku - Go to 1&1 and create a
CNAME
record pointing tomyherokuapp.herokuapp.com
回答2:
What worked for me was to user Namecheap.com
's FreeDNS
service that provides free automatic redirect for your TLD and subdomains directly to Heroku, while keeping your domain visible:
example.com
and www.example.com
now point to exampleapp.herokuapp.com
I had to have a live chat with Namecheap's support to complete the domain verification process, but they answered really fast! Love to namecheap, 1and1 is really crappy, moving my domains away soon. :)
回答3:
I found this video to be helpful - https://www.youtube.com/watch?v=ZLVBBAnrrL4
Basically, as noted by @Kevin Lawrence above, you use the 'www' subdomain.
回答4:
I've never used 1&1 but my DNS provider (dreamhost) does not allow CNAMEs on the main domain name either. It does however allow me to create a CNAME for the www subdomain which was good enough in my case.
I did this:
- heroku domains:add www.mydomain.com
- create a CNAME record pointing to mydomain.herokuapp.com
- Have mydomain.com redirect to www.mydomain.com
It's not exactly what I wanted (or what you want) but it works.
回答5:
I got this to work properly! No need for CNAME at all. Create a A record in heroku like in this link - creating a custom room domain - provided by heroku (of course, change example.com to your root domain):
heroku domains:add example.com
Here, example.com is the ROOT domain. Once you get an A record, execute the following command
heroku domains:wait example.com
Now verify your domain has been provisioned:
heroku domains -a [your custom heroku app name]
And you get this:
=== [your custom app name] Custom Domains
Domain Name DNS Record Type DNS Target
example.com ALIAS or ANAME elliptical-blueberry-1euo3460fyrtc8zdgulv0f7o.herokudns.com
Next, get the IPv4 IP address of elliptical-blueberry-1euo3460fyrtc8zdgulv0f7o.herokudns.com
I got it by using a lookup service.
Updating 1 and 1
- Go to 1and1.
- Click the DNS tab for your custom domain e.g. example.com
- Delete the existing A record
- Create a new A record and enter in the @ symbol if it asks you, or else I think it is the default AND enter in the IPv4 address
- For testing this out, make the TTL 1 min until it's stable
- Give it time to propagate. Could be a few minutes to 24 hours.
来源:https://stackoverflow.com/questions/42434704/11-domain-pointing-to-heroku