[英]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:我正在使用 Laravel 5.8 开发我的项目,在这个项目中,我添加了这条路线:
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.因此,当我转到 url
sitename.com/tavana/
,它应该从TavanaStaticController
Controller 检索数据。
But now the problem I'm facing is that, it shows 403 Forbidden :但现在我面临的问题是,它显示403 Forbidden :
Forbidden You don't have permission to access this resource.
Forbidden您无权访问此资源。
This is strange, because it used to work fine!这很奇怪,因为它曾经可以正常工作!
So what's going wrong here?那么这里出了什么问题呢? How can I solve this issue?
我该如何解决这个问题?
Run the following command and see if a middleware is specified for this path or not运行以下命令,查看是否为该路径指定了中间件
php artisan route:list
In the middleware column you will see the items that cause you to make a 403 error.在中间件列中,您将看到导致您出现 403 错误的项目。 Check out that middleware
看看那个中间件
It was basically because of these codes written at .htaccess
file in public
directory:这基本上是因为这些代码写在
public
目录中的.htaccess
文件中:
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.因此,当我在我的网站上访问类似
/example
的 url 时,它会在public
目录中搜索,如果不存在任何具有相同名称的文件夹名称,则它将调用 Controller 及其方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.