Codeigniter资产文件夹最佳实践 [英] Codeigniter assets folder best practice

查看:78
本文介绍了Codeigniter资产文件夹最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对codeigniter很新,但我学得很好,我要添加一个 css,images,js,... 文件夹,但我不知道在哪里

I'm fairly new to codeigniter, But i'm learning well, I'm going to add a css, images, js, ... folder but I'm not sure where to put it

有人告诉我要建立一个「公开」资料夹。

Someone told me to make a 'public' folder

system
application
public
    css
    images

然后在你的index.php(在公共文件夹中)相应地调整

And then in your index.php ( in the public folder ) adjust accordingly

$ system_path ='../system';
$ application_path ='../ application';

$system_path = '../system'; $application_path = '../application';

但是当我这样做时,我得到一个404(不是ci 404,找到一个)

But when I do that i get a 404 ( not the ci 404, but a really-not-found one )

任何人都知道我可能做错了什么?谢谢!

Anyone has any idea what I might be doing wrong? Thanks!

推荐答案

另一个角度 - 我想他们试图告诉你做 - &系统文件夹一级从publichtml文件夹。这样你的源文件是不可访问的。所以像Mamp中的公共文件夹被称为htdocs,在大多数web托管其调用html。

another angle on this -- and i think what they were trying to tell you to do - is putting your application & system folders one level up from the "public" html folder. that way your source files are not accessible. so like in Mamp the public folder is called htdocs, in most web hosting its called html.

 /application/html/
 /system     /html/

 // your main index page is in the public html folder
 /.…..       /html/index.php 

 // an assets folder in the public html folder with css, img, etc folders
 /.……        /html/assets/css/
 /.……        /html/assets/img/

那么在你的index.php中,路径会向上一层。

then in your index.php, the path is going one level 'up' like

$system_path = '../system';
$application_folder = '../application';

奖金 - 这里有两个提示帮助了我很多。
1)命名您的应用程序文件夹,然后可以轻松地在不同版本之间切换,
'快速回滚'等。

BONUS - here are two tips that have helped me a lot. 1) Name your application folder, then you can easily switch between different versions, 'roll back' very quickly, etc.

 /app_alpha/html/
 /app_beta01/html/
 /app_beta02/html/

2)将基本url放在index.php页面 - 而不是在配置。

2) Put the base url on the index.php page -- not in the config.

   $assign_to_config['base_url'] = 'https://awesomedomain.com'; 

这样你可以有一个本地开发版本,单独的活动服务器版本 - 担心写基本url,因为它在index.php页面 - 不是在配置。

that way you can have a local development version, separate live server version -- and you never have to worry about over writing the base url because its on the index.php page - not in the config.

这篇关于Codeigniter资产文件夹最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆