rails routes.rb 中的匹配重定向次数过多 [英] match in rails routes.rb is redirecting too many times
问题描述
我有一条路线应该匹配这样的路线
本地主机:3000/站点/管理员
I have a route that is suppose to match something like this
localhost:3000/site/admin
并重定向到
本地主机:3000/en/site/admin
localhost:3000/en/site/admin
这是应该匹配的路线
路线.rb
here is the route line that should match this
routes.rb
match '*path', to: redirect("/#{I18n.default_locale}/%{path}")
但不是匹配它并重定向到 localhost:3000/en/site/admin,而是重定向到此
but instead of matching it and redirecting to localhost:3000/en/site/admin, It's redirecting infite to this
http://localhost:3000/en/en/en/en/en/en/en/en/en/en/en/en/en/site/admin
(adds /en until browser complains about infite loop)
知道为什么会发生这种无限循环吗?谢谢
Any idea why this infite loops is happening? Thanks
编辑
链接到我的整个 routes.rb 文件
Link to my my entire routes.rb file
https://gist.github.com/2323762
推荐答案
在文件中是否有更高的路由可以捕获要重定向到的/:locale/:path" URL?如果没有,您的路线将失败并再次被*path"路线(匹配任何内容)捕获.
Do you have a route higher up in the file that catches the "/:locale/:path" URL that you're redirecting to? If not, your route will fall through and be caught once again by the "*path" route (which matches anything).
这篇关于rails routes.rb 中的匹配重定向次数过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!