Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

felloz's avatar

404 with some ID's

Hello,

I have this route, but for some reason when the student id its 10 or higher I receive 404 error, but lower ID open correctly.

http://localhost/students_report/7 Good!

http://localhost/students_report/11 Error 404!

I checked the student with 11 id and already exist!

It's something wrong with my route?

//Students Report
Route::get('/students_report/{student}', 'StudentController@studentReport')
    ->where('student', '[0-9+]')
    ->middleware('auth');

Laravel versión 8 upgraded from 6, 7, 8.

Note: I modified my Route Service Provider to keep old routes.

0 likes
2 replies
MichalOravec's avatar
Level 75

It's a problem with regex. Change it to

[0-9]+
felloz's avatar

Not even a semicolon give it to me so much headache /facepalm

Thank you!

Please or to participate in this conversation.