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

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

    I had this error and i just pasted the http://127.0.0.1:8000/ directly into the url bar. you get the below when you type : php laravel serve

    i was putting in localhost/http://127.0.0.1:8000/ to get the error you mentioned.

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

    If you have tried all .htaccess answers from comments and none of them worked, it's possible that actually you have bad APP_URL in you .env config file. That worked for me.

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

    It was solved for me with the Laravel default public/.htaccess file adding an extra line:

    The /public/.htaccess file remains as follows:

    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>
    
        RewriteEngine On
        DirectoryIndex index.php # This line does the trick
    
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        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>
    
    0 讨论(0)
  • 2020-11-30 02:13

    I had the same problem and builded a .htaccess file to fix this issue with a few more improvements. You can use it as it is, just download it from Github Gist and change the filename "public/index.php" to "public/app.php" and see how it works! :)

    0 讨论(0)
  • 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:

    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>
    
        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]
    </IfModule>
    

    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

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

    I met the same issue, then I do same as the solution of @lubat and my project work well. :D My virtualhost configuration:

    <VirtualHost *:80>
         ServerName laravelht.vn
         DocumentRoot D:/Lavarel/HTPortal/public
         SetEnv APPLICATION_ENV "development"
         <Directory D:/Lavarel/HTPortal/public>
             DirectoryIndex index.php
             AllowOverride All
             Require all granted
             Order allow,deny
             Allow from all
         </Directory>
     </VirtualHost>
    
    0 讨论(0)
提交回复
热议问题