实际目录覆盖Laravel路由 [英] Actual directory overwriting Laravel route

查看:101
本文介绍了实际目录覆盖Laravel路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与Laravel合作开发第一个项目,这是一个带有管理面板的简单网站:

I'm working in my first project with Laravel, it's a simple website with an admin panel:

在我的公共"文件夹中,有一个名为"admin"的目录,在其中放置了与管理面板相对应的所有样式和脚本.我还在应用程序中定义了处理管理员" GET的路由:

In my "public" folder I have a directory called "admin" where I put all the styles and scripts corresponding to the admin panel. I've also defined a route in my app to handle the "admin" GET:

Route::get('/admin', 'Admin\DashboardController@index');

问题是,由于我的公共目录中有那个"admin"文件夹,Laravel忽略了我定义的"admin"路由,所以我无法访问适当的控制器.我怀疑它与.htaccess有关,但不确定如何解决.这是我现在的htaccess的样子:

The problem is that since I have that "admin" folder in my public directory Laravel is ignoring the "admin" route I defined, so I can't access the proper controller. I'm suspecting it has something to do with the .htaccess but I'm not sure how to solve it. This is how my htaccess looks right now:

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On

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

推荐答案

您不能拥有与路径名称相同的公共目录-否则Laravel将如何知道"/admin"是用于控制器还是用于样式等

You cannot have a public directory with the same name as your route - otherwise how will Laravel know whether "/admin" is for the controller, or for the style etc.

您应将管理样式表等存储在/assets/admin/*

You should store your admin style sheets etc under /assets/admin/*

这篇关于实际目录覆盖Laravel路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆