作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有一种方法可以创建带有前缀的路由,所以我可以拥有这样的路由
/articles.html -> goes to listing Controller in default language
/en/articles.html -> goes to the same controller
/fr/articles.html -> goes to the same controller
Route::group(['prefix=>'/{$lang?}/',function(){});
/authors/author-100.html
将匹配前缀'authors',并且肯定没有称为“authors”的语言。
最佳答案
似乎没有任何好的方法来使用可选前缀,因为带有“可选”正则表达式标记的组前缀方法不起作用。但是,可以使用所有路由声明一个Closure,并使用前缀添加一次,而不使用前缀添加一次:
$optionalLanguageRoutes = function() {
// add routes here
}
// Add routes with lang-prefix
Route::group(
['prefix' => '/{lang}/', 'where' => ['lang' => 'fr|en']],
$optionalLanguageRoutes
);
// Add routes without prefix
$optionalLanguageRoutes();
关于Laravel使用regexp的可选前缀路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46032537/
我正在尝试用 Swift 编写这段 JavaScript 代码:k_combinations 到目前为止,我在 Swift 中有这个: import Foundation import Cocoa e
我是一名优秀的程序员,十分优秀!