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

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

问题描述



如果我已经购买了一个域名,那么我无法将子域路由到Heroku上托管的Wordpress博客,根域也是另一个Heroku应用程序。在NameCheap上称为 cheese.com ,我想要路由一个子域,如 blog.cheese.com 我怎么可能在Heroku上这样做?



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

解决方案

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



子域



blog.cheese.com将有一个CNAME记录指向myblog.herokuapp.com,您可能还想为www.blog.cheese.com创建一个CNAME记录。



示例记录可以是:

 名称:blog.cheese.com 
TTL :14400
类型:CNAME
地址:myblog.herokuapp.com

一次两个CNAME记录都设置好了,你需要告诉heroku将域指向你的应用程序。

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

如果你对这两个子域都这样做,他们应该现在指向您的Heroku应用程序。



根域



指向根您需要设置几个记录

 主机名:@ 
URL:http:// www。 C heese.com
记录类型:URL重定向

主机名:www
URL:mymainpage.herokuapp.com
记录类型:CNAME(别名)

一旦这两个记录都设置好,只需通过Heroku调用下面的命令来指向您的域名。

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

这里有几个地方可以寻找额外的信息。



点击nokecheap域到Heroku



自定义域名Heroku开发中心


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 cheese.com on NameCheap and I'd like to route a subdomain like blog.cheese.com how could I do this on Heroku?

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

解决方案

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.herokuapp.com 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

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

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