I'm learning laravel and I have a problem with my base url which is http://localhost/
.
It keeps redirecting to http://localhost/home
which is the base authentication route and since im not logged in, it redirects me to http://localhost/login
.
I want http://localhost/
to redirect to http://localhost/blog/posts
as it should.
I'm doing this because in the future the base url will redirect to another page. Until then, I want to display the blog posts.
web.php
Route::get('/', [
'as' => 'index',
'uses' => 'HomeController@index',
]);
Route::get('/blog/posts', [
'as' => 'blog',
'uses' => 'BlogController@index'
]);
Auth::routes();
Route::get('/home', [
'as' => 'home',
'uses' => 'HomeController@home'
]);
HomeController.php
public function home()
{
return view('home');
}
public function index()
{
return view('blog');
}
I hope I was clear enough, i'd be glad to give more info if needed.
Comment or remove $this->middleware('auth');
in HomeController.php and add it in the route:
Route::get('/home', [
'as' => 'home',
'uses' => 'HomeController@home'
])->middleware('auth');
Check that the HomeController __construct() function
doesn't have an auth middleware
inside, that would try to log you in first, then continue to check for the index function.