Laravel路由:使用逗号而不加斜杠

问题描述 投票:0回答:1

我正在建立一个网站来使用Laravel 6列出和搜索广告。

基于建议,我希望“搜索引擎友好”的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.html

Route::get('/sale/{slugs?}.html', 'AdsController@search')->where('slugs', '(.*)');

但这不是我想要的。如何在sale和{slugs}之间用“,”替换第一个“ /”?

谢谢

laravel routing seo
1个回答
0
投票

我刚刚测试了以下内容:

Route::get('/sale{slugs?}.html'

正在使用http://[host]/sale,shoes,new-york,xl,6,10.html

但是这是Laravel 4.2.22,但我相信这也应该对您有用。

© www.soinside.com 2019 - 2024. All rights reserved.