codeigniter and cpanel installation

10,736

Directory structure

If at all possible, it's advised that you keep your system and application folders above the web root. Your index.php file needs to be accessible from a browser, so that should go in your public_html folder. Here's a possible directory structure that you could use:

-/home/edd
    -public_html
        -index.html
        -.htaccess
    -system
    -application

You can rename your system and application folders, or create another sub-directory to put them in, if you want.


index.php

Within index.php you'll need to update $system_path and $application_folder to reflect the location and name of your system and application folders. You can use an absolute path or a relative path. Relative path shown below:

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

.htaccess

The first two sections of your .htaccess file are there to prevent a user from accessing your system and application folders. If you're storing them above the web root then you don't really need this. If you keep them, then you need to update the paths. This file should be located in your public_html folder.


application/config/config.php

As you've already correctly done, the index.php value should be removed from the index_page config, so index.php can be removed from your url using your .htaccess file;

$config['index_page'] = 'index.php';

should be changed to:

$config['index_page'] = '';

You may also have to make this change:

$config['uri_protocol'] = 'REQUEST_URI';

(If you have no luck with this value, try the others. One should work!)


application/config/routes.php

$route['default_controller'] = "home_controller";

(Assuming that is the name of your controller.)


Your site is likely to depend on some assets, such as CSS and JavaScript. These should go in your web root - public_html. You can organise these file however you like.

Share:
10,736

Related videos on Youtube

Undermine2k
Author by

Undermine2k

Before: (╯°□°)╯︵ ┻━┻ After: ♪└(・。・)┐♪ ┬───┬

Updated on June 04, 2022

Comments

  • Undermine2k
    Undermine2k almost 2 years

    I am completely new to moving codeigniter to my web-server and im having trouble with the configuration. Where do I place my codeigniter project folder in www under myurl.com in in the very root directory? Am i supposed to move out the application and system folders?

    I am trying to remove index.php? from my URL name where do i place my .htaccess file in the root or in the same folder as my codeigniter directory?

    I wish to be able to type in (www.myurl.com) and be redirected to my home_controller/index is this possible?

    enter image description here

    below is my .htaccess file in it's entirety

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /MMSFL/
    
    
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    </IfModule>
    
    <IfModule !mod_rewrite.c>
    
    
    ErrorDocument 404 /index.php
    </IfModule>
    

    I have also made the following changes in config/routes

        $config['index_page'] = "";
        $config['base_url'] = "http://myurl.com/";
        $config['server_root'] = $_SERVER['DOCUMENT_ROOT'];
        $config['uri_protocol'] = 'AUTO';
    
    $route['default_controller'] = "home_controller";