简体   繁体   English

Laravel路由中包含文件夹名称

[英]Laravel routes have folder name in it

When i hit url the route needs to be configured with a prefix folder name ie "laravel/" for example For Url: http://localhost/laravel/someurl 当我点击url时,路由需要配置一个前缀文件夹名称,例如“ laravel /”对于网址: http:// localhost / laravel / someurl

Route::get('laravel/someurl', function () {
return "asdasd";
});

How to remove the folder name for appearing in routes 如何删除出现在路线中的文件夹名称

if you just want add some prefix you can use below code for group of code 如果您只想添加一些前缀,则可以将以下代码用于代码组

Route::group(['prefix' => 'app'], function () { 
  Route::get('package_type',['as'=>'package_type','uses'=>'UserController@package_type']);
});

for getting this root you need to hit 为了获得这个根,你需要打

your_url.com/app/package_type

hope this is what you need 希望这就是你所需要的

If you want to remove folder prefix, you should set web server document root to public folder. 如果你想删除的文件夹前缀,你应该设置网络服务器的根目录到public文件夹。 For example, if use php-cli to run PHP simple server, use option -t to change document root: 例如,如果使用php-cli运行PHP简单服务器,则使用选项-t更改文档根目录:

php -S localhost:80 -t /path/to/laravel-project/public

Now, you can see that prefix is gone. 现在,您可以看到前缀消失了。

Similarly, if you use other servers such as Apache or Nginx , you only need to modify the settings. 同样,如果您使用其他服务器,例如ApacheNginx ,则只需修改设置。

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

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