如何将子域指向 Heroku 应用程序,将根域指向另一个 Heroku 应用程序? [英] How to point subdomain to a Heroku app, and root domain to another Heroku app?

查看:20
本文介绍了如何将子域指向 Heroku 应用程序,将根域指向另一个 Heroku 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将子域路由到 Heroku 上托管的 Wordpress 博客,并将根域路由到另一个 Heroku 应用.

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

如果我在 NameCheap 上购买了一个名为 cheese.com 的域,并且我想路由一个像 blog.cheese.com 这样的子域,我该怎么做?Heroku?

If I have purchased a domain called cheese.com on NameCheap and I'd like to route a subdomain like blog.cheese.com how could I do this on Heroku?

我需要在每个 Heroku 应用程序上放置什么类型的设置?

What type of setting would I need to place on each Heroku application?

推荐答案

我不确定 NameCheap 的确切方向,但将子域重定向到 Heroku 应用程序的一般方法是向子域添加 CNAME 记录.要重定向根域,您需要在区域顶点设置类似 CNAME 的功能.

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.

子域

blog.cheese.com 会有指向 myblog.herokuapp.com 的 CNAME 记录,您可能还想为 www.blog.cheese.com 创建 CNAME 记录.

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.

示例记录可以是:

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

设置好两条 CNAME 记录后,您需要告诉 heroku 将域指向您的应用.

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

如果您对两个子域都执行此操作,它们现在应该指向您的 Heroku 应用程序.

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

根域

要指向根域,您需要设置几条记录

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)

设置好两条记录后,只需通过 Heroku 调用以下命令即可将您的域指向它.

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.

将 namecheap 域指向 Heroku

自定义域 |Heroku 开发中心

这篇关于如何将子域指向 Heroku 应用程序,将根域指向另一个 Heroku 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆