因此,我将 Rails (3.0.9) 应用程序从一个域移动到另一个域.Heroku 建议在应用程序控制器中使用 before_filter 以确保每个人都进入新域,如下所示:
So, I'm moving my rails (3.0.9) app from one domain to another. Heroku suggests using a before_filter in the application controller to make sure that everyone ends up on the new domain, like so:
before_filter :ensure_domain if Rails.env.production? APP_DOMAIN = 'www.newdomain' def ensure_domain if request.env['HTTP_HOST'] != APP_DOMAIN redirect_to "#{APP_DOMAIN}", :status => 301 end end但是,在某些控制器视图上,我使用了 ssl_requirement,我相信它会做同样的事情,但会强制使用 ssl 协议.
However, on certain controller views I'm using ssl_requirement, which I believe does the same thing but forces ssl protocol.
我对请求处理和所有爵士乐并不那么聪明.我的问题是,这两个是否会创建一个无限循环,其中 SLL 尝试重定向到 https,而 before 过滤器尝试将其放回 http?
I'm not that smart about request handling and all that jazz. My question is, are these two going to create an infinite loop, where SLL tries to redirect to https and the before filter tries to put it back to http?
你会如何解决这个问题?
How would you solve this issue?
推荐答案只要尊重当前协议:
redirect_to("#{request.protocol}#{APP_DOMAIN}", :status => 301)更多推荐
Rails:重定向到特定域...但不要覆盖 SSL?
发布评论