我使用命令make:auth并显示:
Created View: /var/www/myblog/resources/views/auth/login.blade.php
Created View: /var/www/myblog/resources/views/auth/register.blade.php
Created View: /var/www/myblog/resources/views/auth/passwords/email.blade.php
Created View: /var/www/myblog/resources/views/auth/passwords/reset.blade.php
Created View: /var/www/myblog/resources/views/auth/emails/password.blade.php
Created View: /var/www/myblog/resources/views/layouts/app.blade.php
Created View: /var/www/myblog/resources/views/home.blade.php
Created View: /var/www/myblog/resources/views/welcome.blade.php
Installed HomeController.
Updated Routes File.
Authentication scaffolding generated successfully!
它看起来很棒,我的主页显示正确。 see picture here
但是当我尝试访问“登录和注册”页面时,出现了问题。 它给了我错误:
Not Found
The requested URL /login was not found on this server.
Apache/2.4.7 (Ubuntu) Server at ...
我输入了php artisan route:在终端列表中我得到了这个:
+--------+-----------+-------------------------+-----------------+-----------------------------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+-------------------------+-----------------+-----------------------------------------------------------------+------------+
| | GET|HEAD | / | | Closure | |
| | GET|HEAD | article | article.index | App\Http\Controllers\ArticleController@index | |
| | POST | article | article.store | App\Http\Controllers\ArticleController@store | |
| | GET|HEAD | article/create | article.create | App\Http\Controllers\ArticleController@create | |
| | DELETE | article/{article} | article.destroy | App\Http\Controllers\ArticleController@destroy | |
| | PUT|PATCH | article/{article} | article.update | App\Http\Controllers\ArticleController@update | |
| | GET|HEAD | article/{article} | article.show | App\Http\Controllers\ArticleController@show | |
| | GET|HEAD | article/{article}/edit | article.edit | App\Http\Controllers\ArticleController@edit | |
| | GET|HEAD | home | | App\Http\Controllers\HomeController@index | web,auth |
| | GET|HEAD | login | | App\Http\Controllers\Auth\AuthController@showLoginForm | web,guest |
| | POST | login | | App\Http\Controllers\Auth\AuthController@login | web,guest |
| | GET|HEAD | logout | | App\Http\Controllers\Auth\AuthController@logout | web |
| | POST | password/email | | App\Http\Controllers\Auth\PasswordController@sendResetLinkEmail | web,guest |
| | POST | password/reset | | App\Http\Controllers\Auth\PasswordController@reset | web,guest |
| | GET|HEAD | password/reset/{token?} | | App\Http\Controllers\Auth\PasswordController@showResetForm | web,guest |
| | GET|HEAD | register | | App\Http\Controllers\Auth\AuthController@showRegistrationForm | web,guest |
| | POST | register | | App\Http\Controllers\Auth\AuthController@register | web,guest |
+--------+-----------+-------------------------+-----------------+-----------------------------------------------------------------+------------+
它与我的期望有点不同。根据我在laracast.com上学到的内容,路由列表应该像" Auth \ login"而不只是"登录" ...想知道这里出了什么问题,是因为我使用的是apache?或其他配置我没有正确设置...寻求帮助
另一个问题: 当我访问www.mydomain.com时,我期望默认的欢迎页面而不是auth的主页,但实际上它给了我auth的主页。但当我试图访问www.mydomain.com/home时,我希望再次看到该主页,而我收到了404找不到的错误让我很困惑。这是我的routes.php:
<?php
/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::resource('article', 'ArticleController');
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/home', 'HomeController@index');
});
答案 0 :(得分:1)
嗨大家我刚刚解决了这个问题。
这个问题肯定与laravel无关,完全是由Apache2设置引起的。
我做的很简单 sudo a2enmod重写 并重新启动服务。