Hello Friends đź‘‹,

Welcome To Infinitbility! ❤️

Today, we are going to fix 403 forbidden error in laravel, here we will see causes of laravel 403 errors and their apropriate solutions.

Currently, we have 2 cases when 403 forbidden error occure, if we got any new case we will also update this post.

Let’s see how laravel forbidden error looks like, where we get this error?

Laravel, 403 forbidden error
javascript, 403 forbidden error

after setup, when you try to run your laravel application, you will get screen looks live above screen shot.

Okey, let’s start today’s topic How to solve 403 forbidden error in laravel?

Here, we are going to solve below cases

  1. .htaccess file issue
  2. Public folder name issue

.htaccess file issue

Majorly, developers face issue due to mis configuration of .htaccess file.

some are put this file in wrong folder, and some have .htaccess code not covering RewriteRule and RewriteCond.

Let’s see right way to conigure .htaccess file.

  1. Create .htaccess file in your project root folder, again here I’m saying root folder not the Public folder.

  2. put below .htaccess code in your .htaccess file.

    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{REQUEST_URI} !^public
        RewriteRule ^(.*)$ public/$1 [L]
    </IfModule>
    

After done this try to access your project in browser. it shuld show your project.

Public folder name issue

Sometimes, some route showing 403 forbidden error and whole website working fine.

it’s occure due to same route name already available in public folder.

you have to write different route name or folder name in public folder.

I hope it’s help you, All the best 👍.