2016-08-21 28 views
0

我是一個新的laraveler,現在我工作與laravel的問題。我想/直接給一個anguler index.html。和其他人路線laravel控制器。但是當\直接。其他路由工作錯誤到views目錄。
\app\Http\route.php喜歡如下:laravel路由工作錯誤,直接到視圖

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

Route::get('scan', "[email protected]"); 
Route::get('check', "[email protected]"); 
Route::get('login', "[email protected]"); 

的directy是一樣的東西如下:

├── 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開放() 「/服務/角laravel /應用/視圖/掃描」 失敗(2:沒有這樣的文件或目錄),客戶端:XXXX,服務器:主機名,要求: 「GET /掃描HTTP/1.1」,主持人: 「banliyun.com:8081」

```

,因爲我是用怎樣的路線工作有點迷惑。有人可以告訴我爲什麼它會路由到/放置laravel索引頁面的目錄。

回答

1

保存index.htmlindex.blade.php/resources/views/index.blade.php並更改下面的代碼路線:

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

AppServiceProvider啓動方法添加下面一行:

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

重命名index.html文件爲index.blade.php,然後按照下面的行中route.php

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