我是一名新的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索引页。
答案 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');
});