質問

I've succeeded in getting www.jamesdong.com and jamesdong.com to point to jamesdong.herokuapp.com. The problem is that once you get there, the address bar shows jamesdong.herokuapp.com rather than www.jamesdong.com or jamesdong.com.

Any idea how I can fix this? Feel free to try to see the problem in your own browser, site is live.

For reference:

heroku domains shows 3 domains:

jamesdong.com
www.jamesdong.com
jamesdong.herokuapp.com

I'm using TigerTech as my domain name provider, the settings are as follows:

  • DNS entry: www.jamesdong.com (I also tried using * in place of www as a wildcard, same problem resulted)
  • Type: CNAME
  • Data: jamesdong.herokuapp.com

And those are all the settings I can edit.

Thanks!

役に立ちましたか?

解決 2

What ended up happening was that my DNS provider didn't allow ALIAS and CNAME changes so I put the below code in my application helper

 before_action :redirect_to_www if Rails.env == "production"

 def redirect_to_www
   unless /www\.jamesdong\.com/ =~ request.url
     uri = URI.parse(request.url)
     uri.host = "www.jamesdong.com"
     redirect_to uri.to_s
   end
 end

他のヒント

Configure it like this

  ALIAS jamesdong.com => jamesdong.herokuapp.com
  CNAME www.jamesdong.com => jamesdong.herokuapp.com

It will be fixed.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top