Welcome Guest, Not a member yet? Register   Sign In
JavaScript, CSS and CI system folder structure
#1

[eluser]Tommy Liu[/eluser]
Dear all,

I am a newbie of CodeIgniter. I try to builder a test system for learning CodeIgniter. I setup Apache server of my domain is http://localhost/ for testing. I have several problems of file structure. Please refer to the code segment as below what I am doing.

Apache server web directory:
Code:
<Directory "/home/test/www">
allow from all
Options +Indexes
Options FollowSymLinks
AllowOverride All
</Directory>

I put the .thaccess file for removing index.php:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

I setup the basic config for CodeIgniter:
[config.php]
Code:
$config['base_url']    = "http://localhost/";
$config['index_page'] = "";

[routes.php]
Code:
$route['default_controller'] = "helloworld";
$route['contactus.php'] = "welcome";

After I setup as above completely, I can get the result successfully. Such as, I type URL http://localhost/, I get the result helloworld.php which I saved it into controllers folder. I type URL http://localhost/contactus.php, I get the result from contactus.php correctly.

But, if my home pages have JavaScript and CSS, I cannot get the result properly. For my directory structure, please refer to segment as below:

Code:
[/home/test/www]
   - js  [This is a folder which is stored all javascript files.]
   - css [This is a folder which is stored all css files.]
   - system [This is a folder which is stored all CodeIgniter system.]
   - user_guide [This is a folder which is stored all CodeIgnite User Guide.]
   - index.php [This is a file which is CodeIgnite default index.php file.]
   - .htaccess [This is a apache's control directory file]
   - testing.html [This is a html file which is I want to test URL http://localhost/testing.html directly.]


I have 3 questions that is:
1. How to config the system to let me access user_guide which I type URL http:\\localhost\user_guide and it actual located at outside CI system folder?

2. How to config the system to let the php result to get the javascript files and CSS files which are stored in js and css folders and they actual located at outside CI system folder?

3. How to config the system to let the testing.html file return the result correctlty which I type the URL http:\\localhost\testing.html and it actaul located at outside CI system folder?


Thank you.
#2

[eluser]berg[/eluser]
Did you try modifying the
Code:
RewriteCond $1 !^(index\.php|images|robots\.txt)
line?
As you can see the line contains arguments that should not be "rewritten." So just add your folders and files to the list between the () separated by | and use \ to escape the dot.




Theme © iAndrew 2016 - Forum software by © MyBB