Laravel Base URL Redirecting To /home For No Reason
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' => '[email protected]',
]);
Route::get('/blog/posts', [
'as' => 'blog',
'uses' => '[email protected]'
]);
Auth::routes();
Route::get('/home', [
'as' => 'home',
'uses' => '[email protected]'
]);
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.
Problem solved:
Comment or remove $this->middleware('auth');
in HomeController.php and add it in the route:
Route::get('/home', [
'as' => 'home',
'uses' => '[email protected]'
])->middleware('auth');
Answer
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.
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms