本文介绍了代码:无法访问样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有以下Codeigniter文件夹的目录结构。您可以看到我已将所有资源放在应用程序根目录的 assets 文件夹中。I have the following directory structure of Codeigniter Folder. You can see that I have put all my assets in the assets folder at the root of the application.基本网址定义为 $ config ['base_url'] =' http://kamran.dev/Codeigniter/application/ ';我试过修改到 $ config ['base_url'] =' http://kamran.dev/Codeigniter/ ';但无效 >任何人都可以看看,告诉我我在这里做错了什么?Can anyone please have a look and tell me what I'm doing wrong here? PS然后我从包含 的应用程序文件夹中删除了.htaccess文件所有 Deny From All这对我有用。但这似乎不是一个好主意。And this worked for me. But that doesn't seem like a good idea.推荐答案这里有多个选项。最简单的方法是将assets文件夹移动到与应用程序相同的级别,以使您的目录结构为:You have multiple options here. The easiest one is to move the assets folder to the same level as the application so that your directory structure is: 应用程序 系统 assets css img jsapplicationsystemassetscssimgjs在具有拒绝所有的.htaccess的文件夹中,它不会被您的Web服务器阻止。Because the assets folder is not in a folder with the .htaccess with Deny From All it won't be blocked by your web server.或者,您可以使用以下规则在assets文件夹中添加.htaccess文件:Alternatively you can add an .htaccess file in the assets folder with the following rule:# /assets/.htaccessAllow from all我没有测试这个,但我认为它应该工作。I haven't tested this but I think it should work.另一种选择是更改.htaccess并在assets文件夹上设置异常,但是它是一个非常糟糕的主意(具有安全隐患),用于删除 Deny From AllAnother option is to change the .htaccess and put an exception on the assets folder but it's a very bad idea (with security implications) to remove the Deny From All without writing alternate rules to lock all folders that shouldn't be accessible.此外,请设置您的 base_urlAlso, set your base_url to the folder containing application, system and assets directories (this folder contains Codeigniter's bootstrap/front controller index.php).此外,我建议您使用base_url()函数回显您的网址:Additionally, I would advise you to echo your urls using the base_url() function:base_url("assets/css/bootstrap.min.css");或呼叫控制器/路由base_url("controller/method"); base_url函数考虑 $ config ['index_page' ] 以及必要的开头/结尾斜杠。The base_url function takes into account the value of $config['index_page'] as well as the necessary leading/trailing slashes. 这篇关于代码:无法访问样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-03 04:28