Support the ongoing development of Laravel.io →
Configuration Requests

So I am wondering how to handle 403 error thrown by .htaccess. I have disabled directory listing with :

Options -Indexes

but then I get just plain "Access forbidden!" page.

In my global.php I handled 403 error:

App::error(function(Exception $exception, $code) {
    Log::error($exception);

    switch ( $code ) {
        case 403:
            return Response::view('errors.403', array(), 403);
...

but it never gets to here. So my question is how do I "catch" 403 error, or should I somehow "throw" it without htaccess?

Thanks

Last updated 3 years ago.
0
Solution

I solved this by adding

ErrorDocument 403 /

in my .htaccess file. It basically redirects 403 errors to base url "/" so it doesn't display any error messages which is acceptable for me.

Last updated 3 years ago.
0

Hi there, Can you please paste your .htaccess file contents? I'm facing the same issue and unsure on how to proceed.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

2u3 2u3 Joined 10 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.