开发者

How to organize site with CodeIgniter?

For example, I've created next structure

application
js
css 
system

Standart .htaccess deny access to any files from js or css folders.

RewriteEngine on
RewriteCond $1 !^(index\.ph开发者_如何转开发p|robots\.txt|img|styles|js)
RewriteRule ^(.*)$ /index.php?/$1 [L]

How would you advise to organize site structure?


I am using the same file structure as yours but have not considered them in my .htaccess file and it works. My .htaccess file looks like this

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

I by echoing the base url then adding the other directories. E.g. for css files it would be

href="<?php echo base_url()?>css/filename.css" 


I've wondered about how to best organize my assets too.

When starting out with CodeIgniter, I read that anything specific to one app should go inside the application folder, and stuff related to multiple apps should go in the systems folder, so I used to put my assets in application/assets/...

Not long ago I read a recommendation to put your assets in folder in the root, either

/css
/images
/js

or

/assets/css
/assets/images
/assets/js

On my current project, I've decided to go with the latter structure.

I'm not quite sure what your question regarding the .htaccess file is?


I've your looking for ideas on how to organize your Controllers in CodeIgniter, I've written a blog post on my thoughts for a best-practices approach to doing so. Check it out: http://caseyflynn.com/2011/10/26/codeigniter-php-framework-how-to-organize-controllers-to-achieve-dry-principles/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜