簡體   English   中英

未找到laravel 5 / auth / login

[英]laravel 5 /auth/login not found

我在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。

在我的項目中,我不得不向Apache配置添加以下指令:

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

您需要為apache啟用mode_rewrite。我在此博客后解決了這個問題
http://www.kingpabel.com/apache-mod_rewrite/

沒有apache,你可以用php artisan serve測試它。 之前,你需要做一些改變.ENV,改變APP_ENV到本地。 然后瀏覽auth \\ login,檢查錯誤。 在我的情況下,錯誤是:找不到PDO。 希望這可能有所幫助。

Apache mod_rewrite

//enable mod rewrite
a2enmod rewrite

//restart apache
service apache2 restart
Route::controllers([
    'auth' => 'Auth\AuthController',
    'password' => 'Auth\PasswordController',
]);

數組末尾的額外逗號可能會導致某些問題?

我有同樣的問題,但那個逗號是我馬上看到的

它可能是供應商包,其自己的路由與您的路徑沖突。

如果您在運行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時會添加這種路由模式)。

找到了解決方案。 這是Apache的一些配置問題。 重新安裝Apache解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM