When routes URL is admin it results in 404 Hi!
For some odd reason if I try to view the admin route it results in in 404 error.
Route::get('admin', function () {
return view('admin.index');
});
If I rename the URL to anything else, it works as expected and it displayed the view.
Have you guys ever experienced something like this? I use Laravel Valet and I would to know how this could be solved.
Thanks!
what is the name of your view blade?
if your blade call index.blade than you can do that
Route::get('/index', function () {
return view('index');
});
and your url the name.dev/index
if your blade in directory call admin than
Route::get('index', function () {
return view('admin/index');
});
url is the same as above
My blade file is stored in admin/index.blade.php and there is no problem with it. As I mentioned, if I rename
Route::get('admin', function () {
return view('admin.index');
});
to
Route::get('admins', function () {
return view('admin.index');
});
it will work just fine. Accessing mysite.dev/admin just results in a 404. Even changing the URL to admin/index will work, but I am curious as to why the admin URL does not.
try to use
Route::get('admin', function () {
return view('admin.index')->name('admin');
});
That returns the same 404 error. Hmm...
Do you have an admin route prefix?
run php artisan route:list and check
Thanks Snapey. Looks correct to me as well :-(
+--------+----------+------------------------+------------------+------------------------------------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+------------------------+------------------+------------------------------------------------------------------------+--------------+
| | GET|HEAD | / | home | App\Http\Controllers\HomeController@index | web |
| | GET|HEAD | admin | | Closure | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
| | 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 |
| | POST | password/email | password.email | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web,guest |
| | GET|HEAD | password/reset | password.request | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest |
| | POST | password/reset | | App\Http\Controllers\Auth\ResetPasswordController@reset | web,guest |
| | GET|HEAD | password/reset/{token} | password.reset | App\Http\Controllers\Auth\ResetPasswordController@showResetForm | web,guest |
| | GET|HEAD | register | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm | web,guest |
| | POST | register | | App\Http\Controllers\Auth\RegisterController@register | web,guest |
+--------+----------+------------------------+------------------+------------------------------------------------------------------------+--------------+
do you have a folder called admin in your public folder?
Wow, not sure how I missed that. Thank you sooooooo much!!!
thanks, man! I ran into the same error today glad that I found this thread...
for admin Auth
step1:
inter into terminal php artisan make:middleware IsAdmin.
please be create field IsAdmin to user at default ->0 if be admin ->1
Please sign in or create an account to participate in this conversation.