CodeIgniter htaccess 问题
我想这是一个一般的 htaccess 问题,而不是专门针对 CodeIgniter 的问题,但是,我在我自己的 CodeIgniter 应用程序上工作时遇到了这个问题。
我在根目录中有一个名为“admin”的文件夹,其中包含 CSS、JS 和图像。如果我输入以下内容:http://example.com/admin/
它会定向到该文件夹。我希望我的 routes.php
文件能够控制所有这些并将用户发送到管理面板。这是路线部分:
$route['admin'] = 'admin';
(我有一个名为 admin 的控制器,并且设置正确)
如何解决此问题?我假设这是一个 htaccess 文件问题。
I guess this is a general htaccess question instead of something specifically for CodeIgniter, however, I came across it doing work on my own CodeIgniter application.
I have a folder in the root directory called "admin" where the CSS, JS, and Images are. If I type in the following: http://example.com/admin/
it directs to that folder. I want my routes.php
file to control all of that and send the user to the admin panel. Here's the route section:
$route['admin'] = 'admin';
(I have a controller that is called admin, and it's setup correctly)
How do I fix this issue? I'm assuming this is an htaccess file issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过 .htaccess 修复它,但这意味着对 javascript 和 css 的请求也将被路由:例如,如果浏览器尝试加载
http://baseurl.com/admin/style .css
,系统将尝试在admin
控制器中提供style.css()
方法的输出,从而导致错误。将您的资源文件夹重命名为更敏感的名称(例如
resources
)怎么样?这样您就不必接触 .htaccess 了。
You can fix it via .htaccess, but that will mean that the requests for the javascript and css will be routed as well: if, for instance, the browser tries to load
http://baseurl.com/admin/style.css
, the system will try to serve the output of thestyle.css()
method in theadmin
controller, leading to an error.How about renaming your resources folder to something more sensitive - for instance,
resources
?That way you won't have to touch the .htaccess either.