Route::get('test/{id}', function(){ return 'test page '; }); // id=xxxxxxxxxx // http://127.0.0.1:8000/test/xxxxxxxxxx // output => test page Exit fullscreen mode https://res.cloudinary.com/practicaldev/image/fetch/s--uPvqdF-y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7gi9h5fmg5lhevqs566v.png #add-condition-id-gt-any-number-integer-unsigned-09 Add condition id => any number integer unsigned = [0-9]+ Exit fullscreen mode #you-can-make-the-condition-on-the-whole-project You can make the condition on the whole project #open-appprovidersrouteserviceproviderphp open app/Providers/RouteServiceProvider.php; public function boot() { Route::pattern('id', '[0-9]+'); parent::boot(); } Exit fullscreen mode #reference Reference https://laravel.com/docs/9.x/routing#parameters-regular-expression-constraints
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners