codeigniter javascript not found错误

首先,我很抱歉我的英语不好,我很西class牙语,如果我做错了,我很抱歉,这是我的第一篇文章。

我在codeigniter 2.1.4中加载javascript文件时遇到问题。 我没有把它加载到我页面的标题中。 css文件装得很好。 此示例尝试加载jquery和bootstrap。

我正在遵循codeigniter文档中的步骤,当我创建codeigniter静态页面“home.php”时,我想使用bootstrap进行设计。

我遵循的教程是: http : //ellislab.com/codeigniter/user-guide/tutorial/static_pages.html

我的文件夹结构:

  • htdocs目录
    • myproject(curriculos)
      • 应用
        • 调节器
          • pages.php
        • 意见
          • 模板
            • header.php文件
          • 网页
            • home.php
            • about.php
      • 系统
      • 资产
        • 引导
          • CSS
            • bootstrap.min.css
          • JS
            • bootstrap.min.js
        • jquery- 2.1.0.min.js

我一直在这个论坛和其他人搜索,我总是找到与base_url()或site_url()相同的例子。 这些是我的:

更新的代码:

<script type="text/javascript" src="assets/bootstrap/js/bootstrap.min.js"> 

我的autoload.php加载了url helper:

 $ autoload['helper'] = array('url'); 

当我尝试加载页面时,我收到以下错误:

 GET http://localhost/curriculos/assets/jquery-2.1.0.min.js 404 (Not Found) GET http://localhost/curriculos/assets/bootstrap/js/bootstrap.min.js 404 (Not Found) GET http://localhost/curriculos/assets/bootstrap/js/bootstrap.min.js 404 (Not Found) 

最奇怪的是,当你点击其中一个时,它会向你显示文件类型正在尝试作为text / html加载,而不是像往常一样作为应用程序/ javascript加载:

加载时出错:文件类型为text / html

你能帮助我吗?

非常感谢您的回复。

您需要更改.htaccess文件,以便它不再重写对’/ assets’的请求。

换句话说,您需要.htaccess文件来忽略对’assets’文件夹的请求,并让浏览器按提供的方式加载url。 试试这个:

 RewriteEngine on RewriteCond $1 !^(index\.php|images|assets|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L] 
  

这是正确的道路。试试吧!

问题是codeigniter提供的.htaccess删除index.php。 请点击此链接: http : //www.codeigniter.com/userguide2/general/urls.html

删除.htaccess中的此代码,您可以加载JavaScript文件:)。

 RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] 

Assets文件夹必须位于应用程序文件夹之外。 像下面的快照。 然后在视图文件中使用以下代码来包含css,js和fonts文件。

codeigniter中css / js / fonts文件的文件夹结构