Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将以字符串 xyz 开头的所有路由重定向到其他路径。
match /\/xyz\/(.)*/ => redirect{ "whateverurl" }
给定正则表达式时,匹配方法似乎不起作用,我用谷歌搜索了很多似乎有与正则表达式有关的选项,但它们用于参数例如
match 'photos/:id' => 'photos#show', :constraints => { :id => /[A-Z]\d{5}/ }
我怎样才能实现它?
怎么样:
match '/xyz/*foo' => redirect('url')
这不是一个正则表达式,它被称为route globbing。更多关于它的信息。