javascript - 为什么 CSS 和 JS 没有加载?

标签 javascript php css codeigniter

我已经用谷歌搜索并尝试了许多对其他人有效但对我无效的解决方案。我不知道为什么。

背景:

我正在学习使用 CodeIgniter 2.2.0。我已经设置了元素结构和以下所有内容,但我仍然无法加载我的 CSS 和 JS。

查看代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head id="Head1">
      <title>   </title>
      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
      <!-- solution 1 I have tried: -->
      <!-- in below line I tried by using constant set in constants.php file under application/config/ folder --> 
      <link rel="stylesheet" href="<?php echo (CSS.'dialog.css' );?>" type="text/css">
      <!-- solution 2 I have tried: -->
      <!-- As my css n script files are under CodeIgniter_2.2.0/assets/css and CodeIgniter_2.2.0/assets/scripts folder respectively -->
      <link rel="stylesheet" href="/assets/css/dialog.css" type="text/css">
      <!-- solution 3 I have tried -->
      <!-- This I tried by using autoload.php settings where I am setting autoload['helper'] = array('url'); -->
      <?php echo link_tag('assets/css/dailog.css');?> </br>
      <script src="../../script/Plugins/jquery.js" type="text/javascript"></script> 
   </head>
</html>

配置:

我也设置了

$config['base_url'] = "http://localhost/";application/config/config.php 文件中。

元素文件夹结构:

我的元素文件夹结构如下:

enter image description here

(Application、System、Assets文件夹在同一层)

.htaccess 文件的内容是:

(.htaccess 文件路径:C:\xampp\htdocs.htaccess )

RewriteEngine on

RewriteCond $1 !^(index\.php|images|js|css|robots\.txt)

RewriteRule ^(.*)$ /index.php/$1 [L]

C:\xampp\htdocs\CodeIgniter_2.2.0\SystemC:\xampp\htdocs\CodeIgniter_2 还有 2 个 .htaccess 文件。 2.0\application文件夹 两者都有单行写:

Deny from all

此外,在 C:\xampp\htdocs\ 中,有一个文件 index.phpindex.php 相同文件放在 C:\xampp\htdocs\CodeIgniter_2.2.0\ 我在其中设置了以下内容

$system_path = 'CodeIgniter_2.2.0/system';
$application_folder = 'CodeIgniter_2.2.0/application';

我在这方面有什么遗漏吗?我无法在我的页面上加载任何 CSS 或 JS 文件。

最佳答案

这是解决方案:只需在根目录的 .htaccess 中进行更改

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

n 它的工作。 :)

关于javascript - 为什么 CSS 和 JS 没有加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26410422/

相关文章:

javascript - 通过 AngularJS 中的弹出窗口传递模型值

javascript - Twitter Api 通过主题标签搜索

php - Yii Framework 2.0 规则日期验证器

html - 文本对齐到绝对底部

javascript - 尝试用 Javascript 编写一些来自维基百科的数学(太阳位置计算)

php - 选择不返回任何内容/php - mysql

php - Laravel 5.5 权限 - 用户没有正确的角色

css - Bootstrap 缩略图填充

css - 强制 <a> 标签与父 <li> 标签具有相同的高度

javascript - angularjs中的异步调用