2016-04-13 20 views
4

我添加的域到我的Heroku的項目:Heroku的自定義網址可以作爲重定向而不是別名

$ heroku domains 
=== diveintoworld Heroku Domain 
diveintoworld.herokuapp.com 
=== diveintoworld Custom Domains 
Domain Name   DNS Target 
───────────────────── ─────────────────────────── 
diveintoworld.com  diveintoworld.herokuapp.com 
www.diveintoworld.com diveintoworld.herokuapp.com 

$ host www.diveintoworld.com 
www.diveintoworld.com is an alias for diveintoworld.herokuapp.com. 

創建CNAME記錄在我的域名設置:

www.diveintoworld.com. CNAME diveintoworld.herokuapp.com. 

併成立了網絡從diveintoworld.com重定向到www.diveintoworld.com

似乎沒有錯過任何東西,但所有這些東西都像重定向一樣工作。
www.diveintoworld.com->diveintoworld.herokuapp.com

但我需要使我的網站在www.diveintoworld.com下可用。 (當用戶看到我的網站,他應該可以看到這個網址,而不是在他的地址線Heroku的網址。)

回答

6

當我運行

curl -s -I www.diveintoworld.com 

它返回一個301這意味着你的應用程序可能會做的意外重定向。

HTTP/1.1 301 Moved Permanently 
Server: Cowboy 
Connection: keep-alive 
X-Powered-By: Express 
Location: https://diveintoworld.herokuapp.com/ 
Vary: Accept, Accept-Encoding 
Content-Type: text/plain; charset=utf-8 
Content-Length: 70 
Date: Thu, 21 Apr 2016 05:34:24 GMT 
Via: 1.1 vegur 

X-Powered-By: Expressexpress.js框架,我假設是你用來開發你的網站之一。你的應用程序代碼中是否有重定向到heroku url的地方?也許一個環境特定的配置,設置應用程序主機?

UPDATE - 解決

問題是HEROKU_URL的在應用程序的配置的配置錯誤。在這種情況下,使用Ghost平臺,並且url的配置文檔可用here

設置HEROKU_URLhttp://www.diveintoworld.com,清除緩存或嘗試在私人標籤中伎倆。

+0

由於它看起來與您的應用程序代碼相關,我們需要查看您的路線以及至少您的家庭控制器操作,以查看是否有任何內容觸發了301. –

+0

@Mark這裏是我的根腳本http://pastebin.com/pm4Ajvni和config.js http://pastebin.com/t7f4e1Kp – rocknow

+0

您是否嘗試用您的自定義域名url替換您的配置哈希中的process.env.HEROKU_URL?只是爲了看看這是否會改變什麼... –