Search code examples
phplaravelrouteslaravel-routinglaravel-5.8

Getting 403 Forbidden error message when trying to access a cusotm route


I'm working with Laravel 5.8 to develop my project and in this project, I have added this route:

Route::namespace('StaticPages')->prefix('tavana')->group(function () {
    Route::get('/', 'TavanaStaticController@index')->name('tavanaMainFrontend');
    ...
});

So when I goto the url sitename.com/tavana/, it should be retrieving data from TavanaStaticController Controller.

But now the problem I'm facing is that, it shows 403 Forbidden:

Forbidden You don't have permission to access this resource.

This is strange, because it used to work fine!

So what's going wrong here? How can I solve this issue?


Solution

  • It was basically because of these codes written at .htaccess file in public directory:

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    

    So when I go to a url like /example on my website, it searches in public directory and if not any folder name exists with the same name, then it will calls the Controller and its methods.