How can I fix Laravel 5.1 - 404 Not Found?

前端 未结 6 1349
小鲜肉
小鲜肉 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:12

    I see the same behaviour of being able to visit the / route but all other pages return a 404 when I first setup Laravel sites.

    In your apache config file httpd.conf or httpd-vhosts.conf you need to enable the directives that can be placed in the .htaccess file.

    Here is an example of my VirtualHost configuration:

    
        ServerAdmin admin@gmail.com
        DocumentRoot "C:/www/laravel_authority-controller_app/public"
        ServerName authoritycontroller.www
        ErrorLog "logs/AuthorityController.www-error.log"
        CustomLog "logs/AuthorityController.www-access.log" common
        
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.4/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks Includes ExecCGI
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   AllowOverride FileInfo AuthConfig Limit
        #
        AllowOverride All
    
        #
        # Controls who can get stuff from this server.
        #
        Require all granted
        
    
    

    The key entry for your issue is AllowOverride All. This should be enough to get the website working but you can also include options and Require all granted if they are consistent across the entire website.

提交回复
热议问题