Tower
Tower

Reputation: 345

Laravel 5 - Sorry, the page you are looking for could not be found

I am trying to redirect the Laravel page to another other that home after login, but it redirects me to home every time. What I've done is: I changed the value of protected $redirectTo = from home to protected $redirectTo = 'S1CheckUserTables';.
I also defined my route in web.php as follows (I beleived that I shall use a named route):

Route::get('/S1CheckUserTables', ['as'=>'S1CheckUserTables', 'uses'=>'S1CheckUserTablesController@index']);

I also tried using the following syntax to fix the issue but it didn't work either:

Route::get('S1CheckUserTables', 'S1CheckUserTablesController@index')->name('S1CheckUserTables');

Would you please tell me what could solve my problem? Thank you very much in advance.

Upvotes: 3

Views: 17700

Answers (1)

lewis4u
lewis4u

Reputation: 15047

Default redirect for laravel after login is to go to /home set in the LoginController:

use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/home';

and there is default middleware RedirectIfAuthenticated

class RedirectIfAuthenticated
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            return redirect('/home');
        }

        return $next($request);
    }
}

and in app/Http/Controllers/Auth/RegisterController.php

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after login / registration.
     *
     * @var string
     */
    protected $redirectTo = '/home';

So that is where you need to make changes in order to work your way...

Upvotes: 3

Related Questions