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
In my case, this error was due to internal links in the server, PHP wasn't able to access those folders unless the proper option for that was added to .htaccess
.
Add the following line after RewriteEngine On
:
Options +FollowSymLinks
For my case was encountering this issue with Laravel 6.x and managed to sort it out by installing an SSL Certificate. Tried playing around with .htaccess but never worked. I'm using the default Laravel 6.x .htaccess file which has the following contents
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# 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]
</IfModule>
Check your virtual host configuration. For Ubuntu you could find it at /etc/apache2/sites-available/yourlaravel.conf It should be like this:
<VirtualHost *:80>
ServerName yourlaravel.com
DocumentRoot "/path/to/your/laravel/project/public"
ServerAlias *.yourlaravel.com
<Directory "/path/to/your/laravel/project/public">
AllowOverride All
Require all granted
</Directory>
The key line is Require all granted
inside <Directory>
.
Hope it helps!
In your VirtualHost write the DocumentRoot to point to your Laravel Application in your home directories. In addition you must add the Directory shown below, with your own path:
<Directory /home/john/Laravel_Projects/links/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
The second step, you must go to your Laravel Project and run the following command.
sudo chmod -R 777 storage bootstrap/cache
At the end restart your apache2:
sudo service apache2 restart
First, update your Virtual Host configuration;
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html/example-project/public
<Directory /var/www/html/example-project/public/>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Then, change both permission and ownership of the asset as illustrated below.
$ sudo chgrp -R www-data /var/www/html/example-project
$ sudo chmod -R 775 /var/www/html/example-project
The problem is the location of the index file (index.php).You must create a symbolic link in the root of the project to public/index.php with the command "ln-s public/index.php index.php"