My Routes are Returning a 404, How can I Fix Them?

前端 未结 18 839
栀梦
栀梦 2020-12-23 10:44

I\'ve just started learning the Laravel framework and I\'m having an issue with routing.

The only route that\'s working is the default home route that\'s attached to

相关标签:
18条回答
  • 2020-12-23 11:24

    the simple Commands with automatic loads the dependencies

    composer dump-autoload
    

    and still getting that your some important files are missing so go here to see whole procedure

    https://codingexpertise.blogspot.com/2018/11/laravel-new.html

    0 讨论(0)
  • 2020-12-23 11:25

    The Main problem of route not working is there is mod_rewrite.so module in macos, linux not enabled in httpd.conf file of apache configuration, so can .htaccess to work. i have solved this by uncomment the line :

    # LoadModule rewrite_module libexec/apache2/mod_rewrite.so
    

    Remove the # from above line of httpdf.conf. Then it will works.
    enjoy!

    0 讨论(0)
  • 2020-12-23 11:26

    I think you have deleted default .htaccess file inside the laravel public folder. upload the file it should fix your problem.

    0 讨论(0)
  • 2020-12-23 11:32

    Using WAMP click on wamp icon ->apache->apache modules->scroll and check rewrite_module Restart a LoadModule rewrite_module

    Note, the server application restarts automatically for you once you enable "rewrite_module"

    0 讨论(0)
  • 2020-12-23 11:32

    Routes

    Use them to define specific routes that aren't managed by controllers.

    Controllers

    Use them when you want to use traditional MVC architecture

    Solution to your problem

    You don't register controllers as routes unless you want a specific 'named' route for a controller action.

    Rather than create a route for your controllers actions, just register your controller:

    Route::controller('user');
    

    Now your controller is registered, you can navigate to http://localhost/mysite/public/user and your get_index will be run.

    You can also register all controllers in one go:

    Route::controller(Controller::detect());
    
    0 讨论(0)
  • 2020-12-23 11:33

    you must be using Laravel 5 the command

      class User_Controller extends Controller {
      public $restful = true;
      public function get_index(){
      return View('user.index');
      }
      }
    

    and in routes.php

      Route::get('/', function()
      {
      return view('home.index');
      });
    
      Route::get('user', function()
      {
      return view('user.index');
      });
    

    Laravel 5 command changes for view and controller see the documentation i was having same error before

    0 讨论(0)
提交回复
热议问题