简体   繁体   English

如何更改laravel中路由系统使用的基本路径

[英]How change the base path use by the routing system in laravel

I'm new in Laravel and I start to set my routes. 我是Laravel的新手,我开始设置路线了。 I use laravel 5.1 on a local wamp server. 我在本地wamp服务器上使用laravel 5.1。

I'm on local, http://localhost/ttt/ goes on /public directory of Laravel. 我在本地, http:// localhost / ttt / go /public Laravel的/public目录。

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 : 并转到http:// localhost / ttt / admin ,我收到一个错误,但是当我这样做时:

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. 我检查配置并更改了config/app.phpurl值,但它不起作用。

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, 您可以在初始路由组中为每个路由添加prefix

App\\Providers\\RouteServiceProvider@map : App \\ Providers \\ RouteServiceProvider @ map

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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