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

rubenochoa's avatar

page not found

I am working on a project from laravel 5.4 to the latest version...everything was okey until using request to navbar.blade.php:

<li class="{{Request::is('home') ? 'active' : ''}}"><a href="/home">Home</a></li>
        <li class="{{Request::is('about') ? 'active' : ''}}"><a href="/about">About</a></li>
        <li class="{{Request::is('contact') ? 'active' : ''}}"><a href="/contact">Contact</a></li>

My routes are:

Route::get('/home', 'PagesController@getHome');
Route::get('/about', 'PagesController@getAbout');
Route::get('/contact', 'PagesController@getContact');
Route::get('/messages', 'MessagesController@getMessages');
Route::post('/contact/submit', 'MessagesController@submit');

My pagesController:

class PagesController extends Controller
{
    public function getHome(){
        return view('/home');
    }
    public function getAbout(){
        return view('/about');
    }
    public function getContact(){
        return view('/contact');
    }
}

I used: composer dumpautoload && php artisan view:clear && php artisan cache:clear && php artisan route:clear && php artisan config:clear

I tryed to make routes to laravel 8 version: '''https://laravel.com/docs/8.x/routing'''

I did everything...

My routeserviceprovider:

            Route::prefix('api')
                ->middleware('api')
                ->namespace($this->namespace)
                ->group(base_path('routes/api.php'));

            Route::middleware('web')
                ->namespace($this->namespace)
                ->group(base_path('routes/web.php'));
        });
}```
0 likes
11 replies
SilenceBringer's avatar

@rubenochoa Request::is is slash-sensitive

in routes you have /home, but checks home (without slash). Remove slash in routes file

rubenochoa's avatar

@silencebringer I have tried that also. Nothing and absolutely nothing and the strange is that confirm that controllers exists by php artisan route:list.

rubenochoa's avatar

you mean:

'''Route::get('/home', 'PagesController@getHome')->name('home');; Route::get('/about', 'PagesController@getAbout')->name('about');; Route::get('/contact', 'PagesController@getContact')->name('contact');'''

Nope, does not work.

SilenceBringer's avatar

@rubenochoa I mean

Route::get('/home', 'PagesController@getHome')->name('home');
<li class="{{Request::routeIs('home') ? 'active' : ''}}"><a href="/home">Home</a></li>
rubenochoa's avatar

Same as usual @silencebringer . When I click /home at address bar it appears:

''' This page isn’t workinglocalhost is currently unable to handle this request. HTTP ERROR 500 '''

MichalOravec's avatar

Remove slash from the line

return view('/home');

It should be only

return view('home');

And I prefer to use Route::is()

So

<li class="{{ Route::is('home') ? 'active' : '' }}">
    <a href="{{ route('home' )}}">Home</a>
</li>
MichalOravec's avatar

I saw your reply... Don't recreate it again... Don't do that anymore!

rubenochoa's avatar
rubenochoa
OP
Best Answer
Level 2

I want to thank you all for your answers. The next point was to use / at routes.....so stu%^& I am feeling.

''' Route::get('/', ['App\Http\Controllers\PagesController','getHome'])->name('home'); and not Route::get('/home', ['App\Http\Controllers\PagesController','getHome'])->name('home'); '''

Please or to participate in this conversation.