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

前端 未结 18 841
栀梦
栀梦 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:41

    I was getting the same problem using EasyPHP. Found that I had to specify AllowOverride All in my <Directory> block in httpd.conf. Without this, Apache sometimes ignores your .htaccess.

    Mine ended up looking like this...

    <Directory "D:/Dev">
        Options FollowSymLinks Indexes
        #### NEXT IS THE CRUCIAL LINE ####
        AllowOverride All                  
        Order deny,allow
        Allow from 127.0.0.1
        Deny from all
        Require all granted     
    </Directory>
    
    0 讨论(0)
  • 2020-12-23 11:42

    Just Run in your terminal.

     composer dump-autoload
    
    0 讨论(0)
  • 2020-12-23 11:42
    1. setup .env file
    2. configure index.html
    3. make sure u have .htaccess
    4. sudo service apache2 restart

    most probably it's due to cache problems

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

    On my Ubuntu LAMP installation, I solved this problem with the following 2 changes.

    1. Enable mod_rewrite on the apache server: sudo a2enmod rewrite.
    2. Edit /etc/apache2/apache2.conf, changing the "AllowOverride" directive for the /var/www directory (which is my main document root): AllowOverride All

    Then restart the Apache server: service apache2 restart

    0 讨论(0)
  • 2020-12-23 11:47
    Route::get('/', function()
    {
    return View::make('home.index');
    });
    
    Route::get('user', function()
    {
    return View::make('user.index');
    });
    

    change above to

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

    You have to use '/'(home/default) at the end in your routes

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

    Don't forget the "RewriteBase" in your public/.htaccess :

    For example :

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /your/folder/public
    
    0 讨论(0)
提交回复
热议问题