4

Even after having a proper route set in my web.php, I am getting the 404 not found error in my Laravel application in local mode.

enter image description here

All the pages are working correctly except this one and I am getting this error with POST method after clicking on submit button on the form. Here is my web.php file.

Route::get('categories/create',"CategoryController@create");
Route::post('categories',"CategoryController@store");

UPDATE: My logs says:

[Wed Mar 21 16:40:22 2018] 127.0.0.1:59460 [404]: /categories - No such file or directory
[Wed Mar 21 16:40:22 2018] 127.0.0.1:59464 [200]: /favicon.ico
[Wed Mar 21 16:41:00 2018] 127.0.0.1:59472 [404]: /categories - No such file or directory
[Wed Mar 21 16:41:00 2018] 127.0.0.1:59476 [200]: /favicon.ico
[Wed Mar 21 16:41:03 2018] 127.0.0.1:59480 [200]: /favicon.ico
[Wed Mar 21 16:41:09 2018] 127.0.0.1:59484 [404]: /categories - No such file or directory
[Wed Mar 21 16:41:09 2018] 127.0.0.1:59488 [200]: /favicon.ico

Here is my View file -> https://pastebin.com/NEukzc5s

12
  • Check my answer below. Commented Mar 21, 2018 at 11:12
  • php artisan route:clear followed by change in /categories to url. Are you using resource in routes if Yes comment that thing and check again Commented Mar 21, 2018 at 11:14
  • Have you tried using a resource route instead of your two routes? Route::resource('categories', 'CategoryController'); Commented Mar 21, 2018 at 11:17
  • Still same! @rahulsm Commented Mar 21, 2018 at 11:17
  • Would you like to share your view of create method? Commented Mar 21, 2018 at 11:21

2 Answers 2

5

you may have same categories named directory in project's public folder. (public/categories)

Just rename that directory to some other name and try.

Sign up to request clarification or add additional context in comments.

1 Comment

Worked! Thanks, brother! It's Eye-Opening stuff!
0

There are several possibilities,

  1. You may not wrote your route entry in auth middleware group
  2. You should have used resource to specify which url specifies controller which is deprecated in latest laravel versions as you need to write route for every single actions you call.
  3. You should always give / before start of every url
  4. If all fine, then you should fire command php artisan route:clear

Check all these possibilities and let me know if error.

10 Comments

1. It is written in the auth middleware group
Are you logged In ?
3. i gave '/' before every route. Still same.
2nd point mean you shouldn't have to use resource controller as it is deprecated
Yes, I am logged in brother. Obviously!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.