How to point subdomain to a Heroku app, and root domain to another Heroku app?

前端 未结 2 1436
故里飘歌
故里飘歌 2021-01-29 19:48

I\'m having trouble with routing a subdomain to a Wordpress blog hosted on Heroku, and the root domain to another Heroku app.

If I have purchased a domain called c

2条回答
  •  醉梦人生
    2021-01-29 20:27

    I'm not sure of exact directions for NameCheap but the general way to redirect a subdomain to the Heroku app would be to add a CNAME record to the subdomain. To redirect the root domain you will need to set a CNAME like functionality at the zone apex.

    Subdomain

    blog.cheese.com would have a CNAME record pointing to myblog.herokuapp.com, you may also want to create a CNAME record for www.blog.cheese.com.

    An example record could be:

    Name: blog.cheese.com
    TTL: 14400
    Type: CNAME
    Address: myblog.herokuapp.com
    

    Once both CNAME records are set up you will need to tell heroku to point the domain to your app.

    heroku domains:add --app myblog blog.cheese.com
    

    If you do this for both your subdomains they should now point to your Heroku apps.

    Root Domain

    To point the root domain you will need to set a couple of records

    Host Name: @      
    URL: http://www.cheese.com                
    Record Type: URL Redirect
    
    Host Name: www            
    URL: mymainpage.herokuapp.com              
    Record Type: CNAME (alias)
    

    Once both records are setup just call the command below via Heroku to point your domains to it.

    heroku domains:add --app mymainpage.herokuapp.com cheese.com
    

    Here are a couple of places to look for extra information.

    Point namecheap domain to Heroku

    Custom Domains | Heroku Dev Center

提交回复
热议问题