Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 403 Forbidden Error

As title said, I got error 403 (title of page) on Laravel project. Locally, it's working, but when I'm trying to put it live, on a web-host/my domain it gives me:

Forbidden
You don't have permission to access / on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I deleted .htaccess file from public folder, and nothing happened. Any solutions?

like image 393
Kiddo Avatar asked Mar 24 '17 22:03

Kiddo


People also ask

Why does 403 Forbidden error occur?

The 403 Forbidden error appears when your server denies you permission to access a page on your site. This is mainly caused by a faulty security plugin, a corrupt . htaccess file, or incorrect file permissions on your server.


2 Answers

Your .htaccess is not parsed by apache because AllowOverride All directive is missing inside virtualhost configuration. .htaccess file is required for Laravel. Put back it. Then change apache virtual host configuration on server to allow .htaccess.

<VirtualHost *:80>
    ServerName www.example.net
    DocumentRoot "/var/www/html/example3"
    <Directory /var/www/html/example3>
         DirectoryIndex index.php
         AllowOverride All
         Require all granted
    </Directory>
</VirtualHost>

Change your virtualhost like this and restart apache by sudo service apache2 restart.

Replace www.example.net and /var/www/html/example3 with correct details.

like image 136
Harikrishnan Avatar answered Sep 29 '22 21:09

Harikrishnan


If you are using your own Request, change the authorize function to return true:

public function authorize()
{
    return true;
}

As simple as that!

like image 44
user10774466 Avatar answered Sep 29 '22 23:09

user10774466