I have this code in my route:
Route::get('/{lang}/post/{id}-{slug?}',function($lang, $id, $slug=null) {
dd($lang, $id, $slug);
})->where('id', '[0-9]+');
site.com/en/post/30 -> Work
site.com/en/post/30-myslug -> Work
site.com/en/post/30- -> 404
Why I get a 404 error? slug is optional.
If I replace the dash with another character for example 'i'
Route::get('/{lang}/post/{id}i{slug?}',function($lang, $id, $slug=null) {
dd($lang, $id, $slug);
})->where('id', '[0-9]+');
site.com/en/post/30i Work
Is there any limitation for the dash character?
Laravel 5.8
Sincerely
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire