Laravel slash after url redirects to root folder

后端 未结 5 602
梦谈多话
梦谈多话 2020-12-18 08:02

I\'m new to Laravel and it seems a great framework but i have a question when it comes to routing. I want to route all get requests to one controller action named PageContro

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-18 08:46

    Since the order matters, try this

    Route::group(array('prefix' => 'admin', 'namespace' => 'Admin', 'before' => 'auth'), function()
    {
        Route::get('/', 'DashboardController@main');
    });
    
    Route::get('/{slug?}', 'PageController@view');
    

    Redirection problem Laravel redirects from URL with trailing slash to URL without trailing slash - default behaviour. (If you enter URL without trailing slash -> no redirect needed) Actual redirection is not the problem. The problem is, Laravel cannot guess right "base" URL and generates wrong redirect URL for you.

    Open up app/config/app.php and set url entry to match root of your project. I guess it is http://www.mysite.com/laravel/public in your case.

提交回复
热议问题