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

前端 未结 24 1524
灰色年华
灰色年华 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:20

    I had a problem with non-www website URL version - the PUT method has been not working. But when entering the website with www. - it works fine!

    0 讨论(0)
  • 2020-11-30 02:21

    Create and put this .htaccess file in your laravel installation(root) folder.

    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{REQUEST_URI} !^public
        RewriteRule ^(.*)$ public/$1 [L]
    </IfModule>
    
    0 讨论(0)
  • 2020-11-30 02:22

    On public/.htaccess edit to

    <IfModule mod_rewrite.c>
     <IfModule mod_negotiation.c>
                  Options -MultiViews
              </IfModule>
    
              RewriteEngine On
    
              # Redirect Trailing Slashes If Not A Folder...
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteCond %{REQUEST_URI} (.+)/$
              RewriteRule ^ %1 [L,R=301]
    
              # Handle Front Controller...
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteRule ^ index.php [L]
    
              # Handle Authorization Header
              RewriteCond %{HTTP:Authorization} .
              RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    </IfModule>
    

    In the root of the project add file

    Procfile
    

    File content

    web: vendor/bin/heroku-php-apache2 public/
    

    Reload the project to Heroku

    bash
    heroku login
    cd my-project/
    git init
    heroku git:remote -a my project
    git add .
    git commit -am "make it better"
    git push heroku master
    heroku open
    
    0 讨论(0)
  • 2020-11-30 02:24

    For those who using Mamp or Mamp pro:

    Open MAMP Pro
    Click on “Hosts”
    Click on “Extended” (UPDATE: Only if you are using MAMP Pro 3.0.6)
    Check “Indexes”
    Click “Save”
    That’s it! Reload your localhost starting page and it should work properly.
    
    0 讨论(0)
  • 2020-11-30 02:24

    This is solved my problem by adding this line:

    DirectoryIndex index.php
    
    0 讨论(0)
  • 2020-11-30 02:24

    For me this was simply calling route() on a named route that I had not created/created incorrectly. This caused the Forbidden error page.

    Restarting the web server allowed proper Whoops! error to display:

    Route [my-route-name] not defined.

    Fixing the route name ->name('my-route-name') fixed the error.

    This is on Laravel 5.5 & using wampserver.

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