Laravel - Forbidden You don't have permission to access / on this server

前端 未结 24 1842
灰色年华
灰色年华 2020-11-30 02:02

My laravel installation was working fine yesterday but today I get the following error:

Forbidden

You don\'t have permission to access / on this server.

Ad         


        
24条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 02:14

    With me the problem appeared to be about the fact that there was no index.php file in the public_html folder. When I typed in this address however: http://azxcvfj.org/public , it worked (this address is just an example. It points to nowhere). This made me think and eventually I solved it by doing the following.

    I made a .htaccess file in the app's root folder (the public_html folder) with this contents:

    
        
            Options -MultiViews
        
    
        RewriteEngine On
    
        # Redirect Trailing Slashes...
        RewriteRule ^(.*)/$ /$1 [L,R=301]
    
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ public/index.php [L]
    
    

    And this worked. With this file you are basically saying to the server (Apache) that whenever someone is trying to access the public html folder(http://azxcvfj.org) that someone who is being redirected is redirected to http://azxcvfj.org/public/index.php

提交回复
热议问题