laravel itself i think mentions that you should use _ https://laravel.com/docs/master/routing#required-parameters
but what is a special character? and what changes to your URL? you need to give some examples
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have two different menu for auth user and guest user. I have added special character in my some of the route url. Like,
Route::get('/admin/reports/sales_by_date', 'ReportController@sales_report_by_date')->name('admin.sales_report_by_date');
I am logged in to my system and When I access this route with some changes into url. It will redirect to 404 page. But the issue is it will change the menu auth to guest just because of special character in route url.
If I remove special character to the route it will work perfectly fine. Also it will not change my menu. Like this,
Route::get('/admin/reports/sales-by-date', 'ReportController@sales_report_by_date')->name('admin.sales_report_by_date');
Does anyone helps me out from this issue.
Thank you in advance.
@shez1983 Thanks for the response but I got the solution for it. And yeah special character means "_" which I have added into my URL --> '/admin/reports/sales_by_date' and when I do some changes like --> '/admin/reports/sales_by_datesddsds' in browser. it will redirect to 404 page but it also change my menu also (auth user menu to guest user menu). It happens because I have added regex for digits and character only for 404 route like,
Route::get('{slug}', function() {
return view('errors.404');
})->where('slug', '([A-Za-z0-9\-"/]+)');
So now I added special character also in my regex and it is working fine now. My route for 404 is:
Route::get('{slug}', function() {
return view('errors.404');
})->where('slug', '([A-Za-z0-9\-\_\%\~\@\#$\^\&\*\(\)\+\.\>\<\:\;\"/]+)');
Please or to participate in this conversation.