Kira
Kira

Reputation: 147

New routes in Laravel are not working

I just tried to add a new route in Laravel but it seems it's not working, just getting 404 errors. It only detects the index '/' route. This code is in the routes/web.php

Route::get('/', 'SiteController@mainView')->name('home');
Route::get('secondroute','SiteController@secondRoute')->name('secondRoute');

The Controller is also working, because it doesnt matter if the index Route (/) is the mainView or SecondRoute so it has to be something with the routing itself?

Thanks

Edit: Mod Rewrite is on

Edit2: I'm using a Ubuntu on a Virtual Machine with Apache 2.4.25

Edit3:

 public function secondRoute(){
    return view('myself', ['title' => 'Myself']);
    }

Upvotes: 0

Views: 582

Answers (1)

user223321
user223321

Reputation: 153

You missed '/' in second route

change

Route::get('secondroute','SiteController@secondRoute')->name('secondRoute');

to

Route::get('/secondroute','SiteController@secondRoute')->name('secondRoute');

Upvotes: 1

Related Questions