未找到laravel 5 / auth / login

时间:2015-05-10 16:48:53

标签: php laravel

我在routes.php进行了一些更改,其余配置是默认配置。 routes.php如下:

//Route::get('/', 'WelcomeController@index');

Route::get('/', 'HomeController@index');

Route::controllers([
    'auth' => 'Auth\AuthController',
    'password' => 'Auth\PasswordController',
]);

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

当我通过http://laravel/访问该网站时,我得到了

  

在此服务器上找不到请求的URL / auth / login。

但如果我使用http://laravel/index.php/auth/login,它的工作没有任何错误。我的路由有什么问题?

我在Windows 7 64位上使用WAMP。

7 个答案:

答案 0 :(得分:6)

您需要为apache启用mode_rewrite。我在此博客后解决了这个问题 http://www.kingpabel.com/apache-mod_rewrite/

答案 1 :(得分:6)

在我的项目中,我必须将以下指令添加到Apache配置中:

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

答案 2 :(得分:4)

没有apache,您可以使用php artisan serve进行测试。在您需要对.env进行一些更改之前,请将APP_ENV更改为本地。然后浏览auth \ login, 检查错误。在我的情况下,错误是:找不到PDO。 希望这可能有所帮助。

答案 3 :(得分:2)

Route::controllers([
    'auth' => 'Auth\AuthController',
    'password' => 'Auth\PasswordController',
]);

数组末尾的额外逗号可能会导致某些问题?

我遇到了同样的问题,但这个逗号是我马上看到的东西

答案 4 :(得分:2)

Apache mod_rewrite

//enable mod rewrite
a2enmod rewrite

//restart apache
service apache2 restart

答案 5 :(得分:1)

可能是供应商包有自己的路径与您的路径冲突。

如果您在运行artisan route:list时出现无法解释的路线,则它们可能属于您最近添加的供应商包。对我们来说,它是“acacha / admin-lte-template-laravel”。

在“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');
    }]);

}

我猜这就是“{one?} / {two?} / {three?} / {four?} /”出现的原因(我认为当供应商使用Route :: controller时会添加此路由模式)

答案 6 :(得分:0)

找到解决方案。这是Apache的一些配置问题。重新安装Apache解决了这个问题。