Michael
Michael

Reputation: 552

Redirecting subdomain for static assets on Heroku

I would like myapp.com/blog to redirect to www.myapp.com/blog. I've installed Refraction to do subdomain redirects at the Rack layer. That doesn't work on Heroku for /blog since my files in /blog are static assets. Any fix?

Upvotes: 2

Views: 632

Answers (1)

iwasrobbed
iwasrobbed

Reputation: 46703

Sounds like you may be making this more difficult than it needs to be.

If you just want myapp.com/something to redirect to www.myapp.com/something, then goto the domain host that is currently handling the myapp.com domain and create a URL redirect record to do just that. This way, the redirect happens at the domain registrar before it even touches your Heroku server (which is how it should be handled).

An example of this would be to create the following records at your domain registrar (i.e. GoDaddy, NameCheap, etc): https://i.sstatic.net/uzoAK.png

Those 3 IP addresses point to Heroku's servers. You should have already set up the custom domain add-on within Heroku if indeed you have some site similar to myapp.com and not myapp.heroku.com

Here's an article / video from Heroku that deals with a little bit of this as well: http://devcenter.heroku.com/articles/custom-domains

Upvotes: 1

Related Questions