OVH与Heroku根域名DNS重定向失败问题求助
Hey there, this is a classic DNS quirk you're hitting—root domains like mysite.com can't use regular CNAME records per DNS standards. A CNAME would overwrite all other records for the domain, but root domains require essential records like SOA and NS to exist, so they conflict. Here's how to fix this specifically with OVH:
Option 1: Use OVH's ANAME/Alias Record (Recommended)
OVH supports ANAME records (sometimes called alias records), which are purpose-built to get around the CNAME restriction for root domains:
- Log into your OVH domain management dashboard and navigate to the DNS settings for
mysite.com - Make sure all existing A records for the root domain are deleted (you already did this step—great job!)
- Add a new ANAME record: leave the hostname field blank (this targets the root domain), and set the target to Heroku's provided
mysite.com.herokudns.com - Save the config and wait for DNS propagation (usually 15 mins to a few hours, depending on your TTL settings)
Option 2: Use OVH's URL Redirect (Alternative)
If you can't set up ANAME right away, you can forward the root domain directly to your working www.mysite.com:
- In your OVH dashboard, find the "Redirects" or "URL Forwarding" section for your domain
- Create a new redirect rule: set the source to
mysite.com, the destination tohttps://www.mysite.com, and choose a 301 Permanent Redirect (best for SEO and long-term use) - Once saved, anyone visiting
mysite.comwill automatically be sent to your working www subdomain, which already points to Heroku
Verify Your Setup
To check if things are working, run this command in your terminal:
dig mysite.com +short
For the ANAME setup, you should see IP addresses associated with Heroku's servers. For the redirect setup, use curl to check the response:
curl -I mysite.com
You'll see a 301 status code pointing to https://www.mysite.com.
Also double-check that mysite.com is properly added to your Heroku app's domain list and that any required ownership verification steps are completed—sometimes that's a hidden culprit!
内容的提问来源于stack exchange,提问作者Maxence

