开发者

Ruby on Rails routing: how to remove (using redirection) a URL prefix

I'm sure this is dead simple, which is why I'm so annoyed...

The problem originated from using translate_routes. This is very simple to use and presents no problem whatsoever. A开发者_如何学Cll I want is to be able to have the default locale prefix in the url, optionally.

Right now, I can do:

GET /controller/ and

GET /fr/controlleur/, but trying

GET /en/controller/ fails.

I figured that the en in the last example is not useful, so I want to 'remove' it using redirection. However, all my attempts up till now have failed.

How can I remove that prefix?


match "/en/*path" => redirect("/%{path}")
  • http://guides.rubyonrails.org/routing.html#redirection
  • http://guides.rubyonrails.org/routing.html#route-globbing
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜