laravel route错误地指向视图

时间:2016-08-21 16:57:28

标签: php laravel

我是一名新的laraveler,现在我解决了laravel问题。我希望/直接指向动物index.html。和其他人路由到laravel控制器。但是当\指向好的时候。其他路由工作错误到views目录    \app\Http\route.php如下:

Route::get('/',function(){
    return File::get(public_path().('/views/index.html'));
});

Route::get('scan', "userController@Scan");
Route::get('check', "userController@Check");
Route::get('login', "userController@Login");
直接就像下面这样:

├── app │ ├── Http │ │ ├── route.php //route file │ ├── Library │ ├── Providers │ ├── Services │ ├── User.php │ └── views
│ │ ├── Index.php // php index file , the entry for nginx server │ └── .......... ├── bootstrap │ ├── app.php │ ├── autoload.php │ └── cache ├── config │ ├── app.php │ └── view.php │ └── .......... ├── public │ ├── bower_components │ ├── css │ ├── data │ ├── index.bak │ ├── index.html //angular index file │ └── scripts │ └── ..........

现在,当我访问http://hostname/scan时,找不到404。

和日志如下: ```  * 2221 open()“/ service / angular-laravel / app / views / scan”失败(2:没有这样的文件或目录),客户端:xxxx,服务器:主机名,请求:“GET / scan HTTP / 1.1”,主机:“banliyun.com:8081”

```

因为我对路线如何工作有点困惑。有人可以告诉我为什么它将路由到/ views目录放置laravel索引页。

2 个答案:

答案 0 :(得分:1)

index.html index.blade.php保存为/resources/views/index.blade.php并将您的路线更改为以下代码:

Route::get('/', function(){
  return view('index');
});

答案 1 :(得分:0)

AppServiceProvider 启动方法中添加以下行:

View::addLocation(public_path('views')); 

index.html文件重命名为index.blade.php,然后按照route.php

中的以下一行
 Route::get('/', function(){
  return view('index');
 });