简体   繁体   English

Laravel路由404错误(找不到页面)

[英]Laravel routing 404 error (Page not found)

I have set up a controller for a sub folder in laravel 5 and I get a 404 error on the url /admin/home 我已经在laravel 5中为子文件夹设置了控制器,并且在url / admin / home上收到404错误

AdminController.php - inside the controllers folder AdminController.php-控制器文件夹内

<?php

namespace App\Http\Controllers;

class AdminController extends Controller
{

    public function __construct()
    {
        $this->middleware('guest');
    }


    public function home()
    {
        return view('admin.home');
    }

}; 

Route.php Route.php

Route::get('home' , 'AdminController@home');

home.php - inside views/Admin home.php-内部视图/管理员

@extends('admin')

@section('content')
<h1>Section admin home</h1>

@stop

Ok i dont see any probleme here except 好的,我在这里看不到任何问题

Route::get('home' , 'AdminController@home');

so the link is not 所以链接不是

exemple.dev/admin/home

But

exemple.dev/home

and also check uppercase and lowercase words (they must be the same if you are on linux) 同时检查大写小写单词(它们必须是相同的,如果你是在Linux上)

return view('Admin.home'); // uppercase

dont make the Route name 'home', this is use as an external command in php.... change it I thing it will work. 不要将路由名称设置为“ home”,这将用作php中的外部命令。...更改它,我会正常工作。

You can use, 您可以使用,

Route::get('index' , 'AdminController@home');
Route::get('anyhing' , 'AdminController@home');

But dont use 'home' :) 但是不要使用'home':)

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

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