How can I fix Laravel 5.1 - 404 Not Found?

前端 未结 6 1370
小鲜肉
小鲜肉 2020-12-29 11:30

I am trying to use Laravel 5.1 for the first time. I was able to install it and https://sub.example.com/laravel/public/ is displaying what is should. However, v

6条回答
  •  醉话见心
    2020-12-29 12:13

    If your Laravel routes aren't working, and you're getting "Not Found" errors whenever you try and load a page, your .htaccess file is likely lacking permission to do its duty.

    The key is the apache AllowOverride directive.

    If you don't have AllowOverride set to All, your Laravel .htaccess file (/public/.htaccess) won't be able to enable mod_rewrite, and your routes won't work.

    The first step is to open your apache httpd.conf file. In OS X, it is located at:

    /private/etc/apache2/httpd.conf
    

    Option 1) Modify your main directive

    This will change the AllowOverride value for all your websites. In your httpd.conf file, look for the main directive:

    
        ...
        AllowOverride None
        ...
    
    

    Simply change it to this:

    
        ...
        AllowOverride All
        ...
    
    

    Option 2) Add a directive to your site's directive.

    
        DocumentRoot "/var/www/html/epigroove/public"
        ...
        
            AllowOverride All
        
    
    

    Save the changes to your httpd.conf file, restart or reload apache, and your routes should be up-and-running.

提交回复
热议问题