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. :)

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

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试