dougu2006 2014-10-16 17:28
浏览 145
已采纳

为什么CSS和JS没有加载?

I have googled and tried many solutions which worked for others but not in my case. I don't know why.

Background:

I am learning to use CodeIgniter 2.2.0. I have set up project structure and all the things as below, but still I am not able to load my CSS and JS.

View Code:

<!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:

Also I have set

$config['base_url'] = "http://localhost/"; in application/config/config.php file.

Project Folder Structure:

My project folder structure is as follows :

enter image description here

(Application , System, Assets folders are at same level)

The contents of .htaccess file are :

(.htaccess file path : C:\xampp\htdocs.htaccess )

RewriteEngine on

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

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

there are 2 more .htaccess file at C:\xampp\htdocs\CodeIgniter_2.2.0\System and C:\xampp\htdocs\CodeIgniter_2.2.0\application folder both have single line written :

Deny from all

Also, at C:\xampp\htdocs\, there is a file index.php which is same as the index.php file placed at C:\xampp\htdocs\CodeIgniter_2.2.0\ in which I have set following things

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

Is there anything that I am missing in this? I am not able to load any CSS or JS files on my page.

  • 写回答

1条回答 默认 最新

  • douzhang5295 2014-10-19 10:51
    关注

    Here is the solution : just make changes in .htaccess at root directory

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

    n its working. :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 Unity的粒子系统使用shadergraph(内置管线)制作的一个顶点偏移shader,但是粒子模型移动时,顶点也会偏移
  • ¥15 如何用python处理excel的数据(极值标准化)
  • ¥15 三向应力状态求剪应力
  • ¥15 jupyter notebook如何添加libGL.so.1库
  • ¥20 easyPoi能否实现下拉多选或者复选框
  • ¥15 网桥在转发帧时,会变帧的源地址和目的地址吗?
  • ¥15 用Multisim设计汽车尾灯控制电路
  • ¥100 求用matlab求解上述微分方程的程序代码
  • ¥15 MAC安装佳能LBP2900驱动的网盘提取码
  • ¥400 微信停车小程序谁懂的来