laravel 5 /auth/login not found

匿名 (未验证) 提交于 2019-12-03 02:56:01

问题:

I've made some change in routes.php and rest configuration is default. routes.php is as follows:

//Route::get('/', 'WelcomeController@index');  Route::get('/', 'HomeController@index');  Route::controllers([     'auth' => 'Auth\AuthController',     'password' => 'Auth\PasswordController', ]); 

Output of php artisan route:list is

+--------+--------------------------------+-------------------------------------------------------+------+------------------------------------------------------------+------------+ | 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

The requested URL /auth/login was not found on this server.

but if I use http://laravel/index.php/auth/login it works without any error. What is wrong with my routing?

I am using WAMP on windows 7 64-bit.

回答1:

You need to enable mode_rewrite for apache.I solved this problem following this blog
http://www.kingpabel.com/apache-mod_rewrite/



回答2:

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



回答3:

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.



回答4:

In my project, I had to add the following instruction to Apache configuration:

<Directory /var/www/html/checkin> AllowOverride All </Directory> 


回答5:

Found the solution. It was some configuration issue with Apache. Re installation of Apache solved the issue.



回答6:

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".

The following code was found in "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).



回答7:

Apache mod_rewrite

//enable mod rewrite a2enmod rewrite  //restart apache service apache2 restart 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!