2

I’m new using codeigniter. I using codeigniter 2.X. I have some question regarding basic course of codeigniter.

  1. What the best suggestion for folder location of our external css/ js /image/another ? For now, i put js/css/or another file on the root, i.e site url/css
  2. How to describe path of image on css and javascript file ? On php its easily that just use <?php echo base_url(); ?> but how in css and javascript?

Both question, I need for the best and experience answer because the answer will be my knowledge base for using codeigniter.

Thank you so much.

1 Answer 1

1

Store your css/js/image in assets folder or as u want

/www
/code_igniter
    /application
    /assets
        +img
        +css
        +js
    /controllers
    /system

then use it in your view as including it

<link type="text/css" rel="stylesheet" href='<?php echo base_url()?>assets/css/mystyle.css'>
<script type="text/javascript" src='<?php echo base_url()?>assets/js/myjs.js'></script>

into your .htacess file add this code

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

put .htaccess file outside the application folder

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

1 Comment

Would you please to tell me what the function of I put htacess on codeigniter folder ? And what the funtion about code of htacess above? Thank you

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.