我正在建立一个网站来使用 Laravel 6 列出和搜索广告。根据建议,我希望“seo 友好”的 url 看起来像这样:https://myawesomewebsite.com/sale,shoes,new-york,xl,6,10.html我试着这样做:Route::get('/sale,{slugs?}.html', 'AdsController@search')->where('slugs', '(.*)');和这个 :Route::get('/{slugs?}.html', 'AdsController@search')->where('slugs', '(.*)');但我收到了 404 错误。我可以使它起作用的唯一方法是:https://myawesomewebsite.com/sale/shoes,new-york,xl,6,10.htmlRoute::get('/sale/{slugs?}.html', 'AdsController@search')->where('slugs', '(.*)');但这不是我想要的。如何在 sale 和 {slugs?} 之间用“,”替换第一个“/”?谢谢
1 回答

九州编程
TA贡献1785条经验 获得超4个赞
我刚刚测试了以下内容:
Route::get('/sale{slugs?}.html', function() {
echo "Works!";
})->where('slugs', '(.*)');
它正在与http://[host]/sale,shoes,new-york,xl,6,10.html
然而,这是Laravel 4.2.22但我相信这也应该对你有用。
- 1 回答
- 0 关注
- 118 浏览
添加回答
举报
0/150
提交
取消