0

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.

3
  • Is it possibly relevant that one instance your CSS files is named dialog and then the other two instances are dailog? Is this supposed to be the same file, or do you have multiple CSS files here? Commented Oct 16, 2014 at 17:39
  • I've answered a question that might be helpful to you: stackoverflow.com/questions/19201362/… Commented Oct 18, 2014 at 16:46
  • What message are you getting in your browser for the files you are loading? 404? Also could you show what your three attempted solutions returned in the HTML? Commented Oct 18, 2014 at 16:48

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.