php - laravel route loading non existing route
Get the solution ↓↓↓
Please am stuck here. i have a laravel project when i access the ROOT route'/'
it keeps redirecting to'/home'
even when the route:'/home'
is not declared. i have cleared the route cache and also check if theredirectIfAuthenticated.php
HOME route is to'/'
on purpose but to no avail. i want assign a controller to the root route
Project is based onlaravel 7.x
. below is myroute/web.php
file:
/* Authentication Routes */
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('verification.verify');
Route::post('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout')->name('logout');
Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('register', 'Auth\RegisterController@register');
Route::get('password/confirm', 'Auth\ConfirmPasswordController@showConfirmForm')->name('password.confirm');
Route::post('password/confirm', 'Auth\ConfirmPasswordController@confirm');
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('password.update');
Route::group(['prefix' => 'user', 'middleware' => ['auth']], function () {
Route::get('/product', 'ProductController@index')->name('user_list_product');
Route::get('/profile/edit', 'HomeController@edit')->name('edit_profile');
Route::get('/product/create', 'ProductController@create')->name('user_create_product');
Route::get('/product/edit/{product_id}', 'ProductController@edit')->name('user_edit_product');
});
Route::get('/', 'HomeController@homepage')->name('homepage');
Route::get('/product/view/{product_id}', 'ProductController@show')->name('view_product');
Copy code
output ofphp artisan route:list
+--------+
Copy code
Undefined asked
2021-12-1
Answer
----+
| Domain | Method | URI | Name | Action | Middleware |
+--------+
Answer
----+
| | GET|HEAD | / | homepage | App\Http\Controllers\HomeController@homepage | web |
| | GET|HEAD | api/category/list | | App\Http\Controllers\API\CategoryController@index | api |
| | GET|HEAD | api/city/find/{findable}/in/{state_code} | api_find_city_in_state | App\Http\Controllers\API\CityController@find_city_in_state | api |
| | GET|HEAD | api/city/list | | App\Http\Controllers\API\CityController@index | api |
| | GET|HEAD | api/city/list_for/{state_code} | api_list_city_for_state_code | App\Http\Controllers\API\CityController@list_city_for_state_code | api |
| | POST | api/login | api_login | App\Http\Controllers\API\AuthController@login | api |
| | POST | api/product/find | | App\Http\Controllers\API\ProductController@find | api |
| | POST | api/product/list | api_list_product | App\Http\Controllers\API\ProductController@index | api |
| | POST | api/register | api_register | App\Http\Controllers\API\AuthController@store | api |
| | GET|HEAD | api/state/find/{findable} | api_find_state | App\Http\Controllers\API\StateController@find_state | api |
| | GET|HEAD | api/state/list | | App\Http\Controllers\API\StateController@index | api |
| | GET|HEAD | api/subcategory/list | | App\Http\Controllers\API\CategoryController@index | api |
| | POST | api/update | api_update | App\Http\Controllers\API\AuthController@update | api |
| | | | | | auth:api |
| | GET|HEAD | api/user/list | | App\Http\Controllers\API\AuthController@index | api |
| | | | | | auth:api |
| | GET|HEAD | api/user/product/delete/{product_id} | | App\Http\Controllers\API\ProductController@destroy | api |
| | | | | | auth:api |
| | GET|HEAD | api/user/product/disable/{product_id} | | App\Http\Controllers\API\ProductController@disable | api |
| | | | | | auth:api |
| | GET|HEAD | api/user/product/find/{findable} | | App\Http\Controllers\API\ProductController@find | api |
| | | | | | auth:api |
| | GET|HEAD | api/user/product/like/{product_id} | | App\Http\Controllers\API\ProductController@like | api |
| | | | | | auth:api |
| | POST | api/user/product/list | api_user_list_product | App\Http\Controllers\API\ProductController@user_index | api |
| | | | | | auth:api |
| | GET|HEAD | api/user/product/report/{product_id} | | App\Http\Controllers\API\ProductController@report | api |
| | | | | | auth:api |
| | POST | api/user/product/save | api_save_new_product | App\Http\Controllers\API\ProductController@store | api |
| | | | | | auth:api |
| | GET|HEAD | api/user/product/unlike/{product_id} | | App\Http\Controllers\API\ProductController@unlike | api |
| | | | | | auth:api |
| | POST | api/user/product/update/{product_id} | api_update_product | App\Http\Controllers\API\ProductController@update | api |
| | | | | | auth:api |
| | POST | email/resend | verification.resend | App\Http\Controllers\Auth\VerificationController@resend | web |
| | | | | | auth |
| | | | | | throttle:6,1 |
| | GET|HEAD | email/verify | verification.notice | App\Http\Controllers\Auth\VerificationController@show | web |
| | | | | | auth |
| | GET|HEAD | email/verify/{id}/{hash} | verification.verify | App\Http\Controllers\Auth\VerificationController@verify | web |
| | | | | | auth |
| | | | | | signed |
| | | | | | throttle:6,1 |
| | GET|HEAD | login | login | App\Http\Controllers\Auth\LoginController@showLoginForm | web |
| | | | | | guest |
| | POST | login | | App\Http\Controllers\Auth\LoginController@login | web |
| | | | | | guest |
| | POST | logout | logout | App\Http\Controllers\Auth\LoginController@logout | web |
| | GET|HEAD | oauth/authorize | passport.authorizations.authorize | Laravel\Passport\Http\Controllers\AuthorizationController@authorize | web |
| | | | | | auth |
| | DELETE | oauth/authorize | passport.authorizations.deny | Laravel\Passport\Http\Controllers\DenyAuthorizationController@deny | web |
| | | | | | auth |
| | POST | oauth/authorize | passport.authorizations.approve | Laravel\Passport\Http\Controllers\ApproveAuthorizationController@approve | web |
| | | | | | auth |
| | POST | oauth/clients | passport.clients.store | Laravel\Passport\Http\Controllers\ClientController@store | web |
| | | | | | auth |
| | GET|HEAD | oauth/clients | passport.clients.index | Laravel\Passport\Http\Controllers\ClientController@forUser | web |
| | | | | | auth |
| | DELETE | oauth/clients/{client_id} | passport.clients.destroy | Laravel\Passport\Http\Controllers\ClientController@destroy | web |
| | | | | | auth |
| | PUT | oauth/clients/{client_id} | passport.clients.update | Laravel\Passport\Http\Controllers\ClientController@update | web |
| | | | | | auth |
| | POST | oauth/personal-access-tokens | passport.personal.tokens.store | Laravel\Passport\Http\Controllers\PersonalAccessTokenController@store | web |
| | | | | | auth |
| | GET|HEAD | oauth/personal-access-tokens | passport.personal.tokens.index | Laravel\Passport\Http\Controllers\PersonalAccessTokenController@forUser | web |
| | | | | | auth |
| | DELETE | oauth/personal-access-tokens/{token_id} | passport.personal.tokens.destroy | Laravel\Passport\Http\Controllers\PersonalAccessTokenController@destroy | web |
| | | | | | auth |
| | GET|HEAD | oauth/scopes | passport.scopes.index | Laravel\Passport\Http\Controllers\ScopeController@all | web |
| | | | | | auth |
| | POST | oauth/token | passport.token | Laravel\Passport\Http\Controllers\AccessTokenController@issueToken | throttle |
| | POST | oauth/token/refresh | passport.token.refresh | Laravel\Passport\Http\Controllers\TransientTokenController@refresh | web |
| | | | | | auth |
| | GET|HEAD | oauth/tokens | passport.tokens.index | Laravel\Passport\Http\Controllers\AuthorizedAccessTokenController@forUser | web |
| | | | | | auth |
| | DELETE | oauth/tokens/{token_id} | passport.tokens.destroy | Laravel\Passport\Http\Controllers\AuthorizedAccessTokenController@destroy | web |
| | | | | | auth |
| | GET|HEAD | password/confirm | password.confirm | App\Http\Controllers\Auth\ConfirmPasswordController@showConfirmForm | web |
| | | | | | auth |
| | POST | password/confirm | | App\Http\Controllers\Auth\ConfirmPasswordController@confirm | web |
| | | | | | auth |
| | POST | password/email | password.email | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web |
| | POST | password/reset | password.update | App\Http\Controllers\Auth\ResetPasswordController@reset | web |
| | GET|HEAD | password/reset | password.request | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web |
| | GET|HEAD | password/reset/{token} | password.reset | App\Http\Controllers\Auth\ResetPasswordController@showResetForm | web |
| | GET|HEAD | product/view/{product_id} | view_product | App\Http\Controllers\ProductController@show | web |
| | POST | register | | App\Http\Controllers\Auth\RegisterController@register | web |
| | | | | | guest |
| | GET|HEAD | register | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm | web |
| | | | | | guest |
| | GET|HEAD | user/product | user_list_product | App\Http\Controllers\ProductController@index | web |
| | | | | | auth |
| | GET|HEAD | user/product/create | user_create_product | App\Http\Controllers\ProductController@create | web |
| | | | | | auth |
| | GET|HEAD | user/product/edit/{product_id} | user_edit_product | App\Http\Controllers\ProductController@edit | web |
| | | | | | auth |
| | GET|HEAD | user/profile/edit | edit_profile | App\Http\Controllers\HomeController@edit | web |
| | | | | | auth |
+--------+
Answer
Solution: From this directoryapp/providers
, openRouteServicePorvider.php
file and edit as follow
/**
* The path to the "home" route for your application.
*
* @var string
*/
public const HOME = '/home';
Copy code
Change to
public const HOME = '/';
Copy code
Share solution ↓
Additional Information:
Date the issue was resolved:
2021-12-1
Link To Source
Link To Answer
People are also looking for solutions of the problem:
too few arguments to function laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.