Rails 3 mod 用折射宝石重写
我正在尝试使用子域 beta.somedomain.com 我希望它重定向到 somedomain.heroku.com/beta
我在这里使用折射宝石:
https://github.com/pivotal/refraction
但我似乎无法让它工作。
尝试过:
intializers 中的 refraction_rules.rb
Refraction.configure do |req|
if req.host == 'beta.somedomain.com'
req.rewrite! "http://beta.somedomain.com/beta/#{req.path}"
end
end
也
Refraction.configure do |req|
if req.host == 'beta.somedomain.com'
req.rewrite! "http://somedomain.heroku.com/beta/#{req.path}"
end
end
尝试过
req.permanent! :host => "beta.somedomain.com"
而不是重写
production.rb
config.middleware.insert_before(::Rack::Lock, ::Refraction)
但两者都不起作用,都只是引导我到 root '/'
I'm trying to use a subdomain beta.somedomain.com and I would like it to redirect to somedomain.heroku.com/beta
I'm using the refraction gem here:
https://github.com/pivotal/refraction
but I can't seem to get it to work.
Tried:
refraction_rules.rb in intializers
Refraction.configure do |req|
if req.host == 'beta.somedomain.com'
req.rewrite! "http://beta.somedomain.com/beta/#{req.path}"
end
end
and
Refraction.configure do |req|
if req.host == 'beta.somedomain.com'
req.rewrite! "http://somedomain.heroku.com/beta/#{req.path}"
end
end
Also tried
req.permanent! :host => "beta.somedomain.com"
Instead of rewrite
production.rb
config.middleware.insert_before(::Rack::Lock, ::Refraction)
But neither works, both just direct me to root '/'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以只使用 Rails 3 的内置路由功能:
检查 Rails Guides< /a> 或此 Rails Dispatch 文章 了解更多信息。
You can just use the built-in routing functionality of Rails 3:
Check the Rails Guides or this Rails Dispatch article for more information.