php laravel 5 /auth/login 未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30154016/
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
laravel 5 /auth/login not found
提问by Nagesh Kinge
I've made some change in routes.php
and rest configuration is default. routes.php
is as follows:
我已经做了一些改变routes.php
,其余配置是默认的。routes.php
如下:
//Route::get('/', 'WelcomeController@index');
Route::get('/', 'HomeController@index');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
Output of php artisan route:list is
php artisan route:list 的输出是
+--------+--------------------------------+-------------------------------------------------------+------+------------------------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+--------------------------------+-------------------------------------------------------+------+------------------------------------------------------------+------------+
| | GET|HEAD | / | | App\Http\Controllers\HomeController@index | auth |
| | GET|HEAD | auth/register/{one?}/{two?}/{three?}/{four?}/{five?} | | App\Http\Controllers\Auth\AuthController@getRegister | guest |
| | POST | auth/register/{one?}/{two?}/{three?}/{four?}/{five?} | | App\Http\Controllers\Auth\AuthController@postRegister | guest |
| | GET|HEAD | auth/login/{one?}/{two?}/{three?}/{four?}/{five?} | | App\Http\Controllers\Auth\AuthController@getLogin | guest |
| | POST | auth/login/{one?}/{two?}/{three?}/{four?}/{five?} | | App\Http\Controllers\Auth\AuthController@postLogin | guest |
| | GET|HEAD | auth/logout/{one?}/{two?}/{three?}/{four?}/{five?} | | App\Http\Controllers\Auth\AuthController@getLogout | |
| | GET|HEAD|POST|PUT|PATCH|DELETE | auth/{_missing} | | App\Http\Controllers\Auth\AuthController@missingMethod | guest |
| | GET|HEAD | password/email/{one?}/{two?}/{three?}/{four?}/{five?} | | App\Http\Controllers\Auth\PasswordController@getEmail | guest |
| | POST | password/email/{one?}/{two?}/{three?}/{four?}/{five?} | | App\Http\Controllers\Auth\PasswordController@postEmail | guest |
| | GET|HEAD | password/reset/{one?}/{two?}/{three?}/{four?}/{five?} | | App\Http\Controllers\Auth\PasswordController@getReset | guest |
| | POST | password/reset/{one?}/{two?}/{three?}/{four?}/{five?} | | App\Http\Controllers\Auth\PasswordController@postReset | guest |
| | GET|HEAD|POST|PUT|PATCH|DELETE | password/{_missing} | | App\Http\Controllers\Auth\PasswordController@missingMethod | guest |
+--------+--------------------------------+-------------------------------------------------------+------+------------------------------------------------------------+------------+
When I access the site via http://laravel/
I get
当我通过http://laravel/
我访问该网站时
The requested URL /auth/login was not found on this server.
在此服务器上找不到请求的 URL /auth/login。
but if I use http://laravel/index.php/auth/login
it works without any error. What is wrong with my routing?
但是如果我使用http://laravel/index.php/auth/login
它,它可以正常工作而不会出现任何错误。我的路由有什么问题?
I am using WAMP on windows 7 64-bit.
我在 Windows 7 64 位上使用 WAMP。
采纳答案by Nagesh Kinge
Found the solution. It was some configuration issue with Apache. Re installation of Apache solved the issue.
找到了解决办法。这是Apache的一些配置问题。重新安装Apache解决了这个问题。
回答by Julien
In my project, I had to add the following instruction to Apache configuration:
在我的项目中,我不得不在 Apache 配置中添加以下指令:
<Directory /var/www/html/checkin>
AllowOverride All
</Directory>
回答by Imtiaz Pabel
You need to enable mode_rewrite for apache.I solved this problem following this blog
http://www.kingpabel.com/apache-mod_rewrite/
您需要为 apache 启用 mode_rewrite。我在此博客http://www.kingpabel.com/apache-mod_rewrite/之后解决了这个问题
回答by Moode Osman
Apache mod_rewrite
Apache mod_rewrite
//enable mod rewrite
a2enmod rewrite
//restart apache
service apache2 restart
回答by Магнайбаяр Ганзориг
Without apache, You can test it with php artisan serve
. Before you need to do some changes in .env, change APP_ENV
to local. then browse auth\login,
check the error. In my case the error is : PDO not found.
Hope this might help.
如果没有 apache,您可以使用php artisan serve
. 在您需要对 .env 进行一些更改之前,请先更改APP_ENV
为 local。然后浏览 auth\login,检查错误。在我的情况下,错误是:找不到 PDO。希望这可能会有所帮助。
回答by Dan Couillard
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
The extra comma at the end of your array may cause something?
数组末尾的额外逗号可能会导致什么?
I'm having the same issue, but that comma is something I saw right away
我有同样的问题,但那个逗号是我马上看到的
回答by Isuru Walpola
It may be a vendor package that has its own routes that conflict with yours.
它可能是一个供应商包,它有自己的路由与你的路由冲突。
If you have unexplained routes showing up when you run artisan route:list, they may belong to a vendor package that you recently added. For us, it was "acacha/admin-lte-template-laravel".
如果您在运行 artisan route:list 时出现无法解释的路由,则它们可能属于您最近添加的供应商包。对我们来说,它是“acacha/admin-lte-template-laravel”。
The following code was found in "acacha/admin-lte-template-laravel/src/app/Providers/AdminLTETemplateServiceProvider.php"
在“acacha/admin-lte-template-laravel/src/app/Providers/AdminLTETemplateServiceProvider.php”中找到以下代码
private function registerRoutes()
{
Route::controller(
'auth', $this->getAppNamespace() . 'Http\Controllers\Auth\AuthController' ,
[ 'getLogin' => 'auth.login',
'getLogout' => 'auth.logout',
'getRegister' => 'auth.register'
]);
Route::controller(
'password' , $this->getAppNamespace() . 'Http\Controllers\Auth\PasswordController',
[ 'getReset' => 'auth.reset',] );
Route::get('/home', ['as' => 'home','middleware' => 'auth', function () {
return view('home');
}]);
}
I guess that's why the "{one?}/{two?}/{three?}/{four?}/" appears (I think this route pattern is added when Route::controller is used by the vendor).
我想这就是为什么会出现“{one?}/{two?}/{three?}/{four?}/”(我认为这个路由模式是在供应商使用 Route::controller 时添加的)。