【发布时间】:2011-05-11 17:55:04
【问题描述】:
我想将所有 IE 用户重定向到一个特定页面,告诉他们我们不支持 IE,他们应该尝试其他浏览器。如何使用 rails 3 路线做到这一点,同时仍允许公共用户查看网站的公共区域?
我的路线是这样的......
MyApp::Application.routes.draw do
constraints(NoSubdomain) do
root :to => 'public#index'
end
constraints(Subdomain) do
root :to => 'internal#index'
end
end
我知道有匹配 user_agent 的功能,但我无法将所有尝试转到网站内部部分 (account.myapp.com) 的用户重定向到 '/ie'页。有什么想法吗?
MyApp::Application.routes.draw do
constraints(NoSubdomain) do
root :to => 'public#index'
end
constraints :user_agent => /MSIE/ do
match "*" => redirect('/ie')
end
constraints(Subdomain) do
root :to => 'internal#index'
end
end
【问题讨论】:
-
真正让事情在 IE 中运行怎么样?我可以理解不支持 IE6 及以下版本,但是来吧......无论如何,浏览器检测是通过用户代理完成的,在 IE 的情况下,它可以通过子字符串 MSIE 来识别。
-
+1 拒绝 IE 用户!!挂他们!!放火烧他们!!
标签: internet-explorer ruby-on-rails-3 redirect routes