Where do I put image files, css, js, etc. in Codeigniter?

前端 未结 14 1134
挽巷
挽巷 2020-11-30 16:57

Where is it acceptable to put css folders and image file folders? I was thinking inside the view folder? However the controller always reroutes the path to the base url so I

相关标签:
14条回答
  • 2020-11-30 17:23

    No one says that you need to modify the .htacces and add the directory in the rewrite condition. I've created a directory "public" in the root directory alongside with "system", "application", "index.php". and edited the .htaccess file like this:

    RewriteCond $1 !^(index\.php|public|robots\.txt)
    

    Now you have to just call <?php echo base_url()."/public/yourdirectory/yuorfile";?> You can add subdirectory inside "public" dir as you like.

    0 讨论(0)
  • 2020-11-30 17:32

    I just wanted to add that the problem may be even simpler -

    I've been scratching my head for hours with this problem - I have read all the solutions, nothing worked. Then I managed to check the actual file name.

    I had "image.jpg.jpg" rather than "image.jpg".

    If you use $ ls public/..path to image assets../ you can quickly check the file names.

    Sounds stupid but I never thought to look at something so simple as file name given the all the technical advice here.

    0 讨论(0)
提交回复
热议问题