简体   繁体   中英

How change the base path use by the routing system in laravel

I'm new in Laravel and I start to set my routes. I use laravel 5.1 on a local wamp server.

I'm on local, http://localhost/ttt/ goes on /public directory of Laravel.

When I try this :

Route::get('admin',function(){
    echo 4;
});

and go to http://localhost/ttt/admin , I got an error but when I do this :

Route::get('ttt/admin',function(){
    echo 4;
});

It work. I check the config and changed the url value in config/app.php but it doesn't work.

Do you know if there is a kind of path used by the router that I can config?

You could prefix each route in the initial route group,

App\\Providers\\RouteServiceProvider@map :

$router->group(['prefix' => 'ttt', 'namespace' => $this->namespace], function ($router) {
    require app_path('Http/routes.php');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM