开发者

redirect from a sinatra app on heroku

I have a very simple sinatra app (teaser page) running on Heroku on a custom domain. All is working well.

I also have a blog. It's running on a different heroku app under the standard heroku domain.

My question:

How can I make my sinatra app redirect 'www.mydomain.com/blog' to the other heroku app (e.g. the blog). Preferably the 'www.mydomain.com开发者_高级运维/blog' url is kept in the address bar of the user's browser..

I think i need some kind of rack redirect in my app, but i have no clue how to get it done..

Help is very much appreciated.

ps I know you can put the blog at blog.mydomain.com, but that is not a solution in our case


You won't be able to redirect to the other heroku app and maintain www.mydomain.com/blog in the address bar. To do what you want in traditional hosting would require a reverse proxy to be setup which is not possible on Heroku - you would see .heroku.com.

If you're happy to redirect to the heroku.com - something like

get '/blog'
  redirect 'http://<appname>.heroku.com'
end

If blog.mydomain.com isn't an option then the only option is to combine the sinatra app and the blog app into one app on www.mydomain.com and go from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜