立即输出缓冲区

Codeigniter:Better folder setup

erhuabushuo posted @ 2012年12月26日 15:07 in PHP , 2022 阅读

This guide is for you to have a better folder setup for your codeigniter. Separate your application folder from the core libraries. Have the bulk of your code outside of your public html folder thus improving security. Then create a public folder to separate the images, css and javascripts.

Step 1:Download Codeigniter

I guess first thing to do is download the latest Codeigniter. Once you downloaded the zip. Unzip it and place it to your server. Either you do it in your localhost using WAMP or upload it to a PHP enabled server.

the basic CI installation on most web servers gives you this folder structure:

we want this:

Step 2: Changing structure

As you see the folder structure on top, I created a public folder. You can create your css, images, js folders here. Move the index.php that’s located at the root to here. Then you can actually just delete the user_guide folder and license.txt.

Edit index.php, the one you moved to the public folder from

?
1
$system_path = 'system';

to

?
1
$system_path = '../system';

Then the application path

?
1
$application_folder = "application";

to

?
1
$application_folder = "../application";

Then make a .htaccess file at the root folder to get rid of the annoying index.php out of the url.

?
1
2
3
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ ci/index.php/$1 [L]

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter