找不到 Laravel 路由 404 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27330960/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:31:48  来源:igfitidea点击:

Laravel routing 404 error not found

phplaravelloginroutes

提问by Josh

So I am learning Laravel in order to make my website more user friendly, I am currently in the process of watching YouTube videos in order to learn Laravel and whilst on this tutorial (https://www.youtube.com/watch?v=aJNKc7GWiAI) I can't seem to access a route.

所以我正在学习 Laravel 以使我的网站更加用户友好,我目前正在观看 YouTube 视频以学习 Laravel,同时在本教程中(https://www.youtube.com/watch?v= aJNKc7GWiAI) 我似乎无法访问路线。

routes.php

路由文件

<?php

Route::get('/', array (
'as' => 'home',
'uses' => 'HomeController@home'
));

/*
Unauthenticated group/not logged in
*/

Route::group(array('before' => 'guest'), function() {

/*
CSRF protection group
*/

Route::group(array('before' => 'csrf'), function() {

});

/*
Create account (GET)
*/
Route::get('/account/create', array (
'as' => 'account-create',
'uses' => 'AccountController@home'
));
});

Account Controller

帐户控制器

<?php
class AccountController extends BaseController {

    public function getCreate() {

    }

    public function postCreate() {

    }


}

Error message

错误信息

The requested URL /laravel/login/public/account/create was not found on this server.

在此服务器上找不到请求的 URL /laravel/login/public/account/create。

The local site is in C:\wamp\www\laravel\login

本地站点在 C:\wamp\www\laravel\login

EDIT: I also uploaded the file to a web server and still not working. here's the url.

编辑:我也将文件上传到网络服务器,但仍然无法正常工作。这是网址。

http://178.62.98.162/laravel/login/public/account/create

采纳答案by Zainul Abideen K T

.htaccessfile is not present at your public folder

.htaccess文件不在您的公用文件夹中

or

或者

your server is not configured to use it

您的服务器未配置为使用它

回答by Khan Shahrukh

First of all edit your root directory in WAMP to laravel/login/public so that you need not to add public in the urls everytime for the same edit the httpd.conf file and/or the vhosts.conf file for the site you wish to change. The Directory directive will let you specify where the files for this site are to be located. Click on the Wamp icon on the left hand side and go through apache/httpd settings and you will get it.

首先,将 WAMP 中的根目录编辑为 laravel/login/public,这样您就无需每次都在 url 中添加 public 以进行相同的编辑 httpd.conf 文件和/或您希望访问的站点的 vhosts.conf 文件改变。Directory 指令将让您指定此站点的文件所在的位置。单击左侧的 Wamp 图标并通过 apache/httpd 设置,您将获得它。