可能重复: 如何将heroku应用DNS配置为Godaddy域名?
我从GoDaddy购买了一个域名,说它是www.mysite,我在Heroku mysite.herokuapp上托管我的应用程序。当我点击mysite.herokuapp时,它应该重定向到www.mysite,我的网站从代码或类似网页到各种页面(例如myapp.herokuapp/users),但(mysite.herokuapp shuld不可访问)
解决方案您应该在您的Rails应用程序中执行此操作。 创建一个检查 HTTP_HOST 变量的Rack中间件。 如果该值与 www.mysite 不匹配,则发送重定向状态码并将用户重定向到正确的路径。
以下是一些您可以从中获得灵感的例子
Possible Duplicate: How to configure heroku application DNS to Godaddy Domain?
I purchased a domain from GoDaddy, say it's www.mysite, and I am hosting my app on Heroku mysite.herokuapp. When I click on mysite.herokuapp it should redirect-to www.mysite, my site to various pages (e.g. myapp.herokuapp/users)from code or similar but (mysite.herokuapp shuld not be accessible)
解决方案You should do it inside your Rails application.
Create a Rack middleware that inspects the HTTP_HOST variable. If the value doesn't match www.mysite, then send a redirect status code and redirect the user to the right path.
Here's a few examples you can start from to get an idea
- How to redirect without www using Rails 3 / Rack?
- github/stjhimy/rack-www
更多推荐
从“mysite.herokuapp.com”重定向到“www.mysite.com”
发布评论