I used the command make:auth and it showed:
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!
It looks like great and I got a homepage showing up correctly. see picture here
But when I was trying to access Login and Register page, something went wrong. It gave me errors like:
Not Found
The requested URL /login was not found on this server.
Apache/2.4.7 (Ubuntu) Server at ...
and I typed php artisan route:list in terminal I got this:
+--------+-----------+-------------------------+-----------------+-----------------------------------------------------------------+------------+
| 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 |
+--------+-----------+-------------------------+-----------------+-----------------------------------------------------------------+------------+
It's a bit different from what I expect. Cuz from what I learned in laracast.com, the route list should be like "Auth\\login" instead of merely "login"... Idk what's going wrong here, is it because I'm using apache? or other configurations I didn't set up correctly... Looking for help
Also another question: when I access www.mydomain.com, I'd expect the default welcome page instead of auth's home page but actually it gives me the auth's home page instead. But when I was trying to access www.mydomain.com/home which I expect to see that home page again, instead I received 404 not found errors which confused me a lot. here is my 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');
});
Hi Guys I just solved this problem.
This problem is definitely unrelated to laravel and is totally caused by Apache2 settings.
What I did is simply sudo a2enmod rewrite and restart service.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.