Skip to content

Instantly share code, notes, and snippets.

@somecuitears
Last active September 14, 2017 18:40
Show Gist options
  • Save somecuitears/0362482627d6e3f1b2e8ce132390287d to your computer and use it in GitHub Desktop.
Save somecuitears/0362482627d6e3f1b2e8ce132390287d to your computer and use it in GitHub Desktop.
Codeigniter
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /codeigniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

Codeigniter Configuration

  1. Download codeigniter project file from https://codeigniter.com/download

  2. Extract and place it inside htdocs or www depending upon the server.

  3. create .htaccess file on the root of the project.

  4. Navigate to application\config\.

  5. open autoload.php and change

    • $autoload['libraries'] = array('database', 'session');
    • $autoload['helper'] = array('url','form');
  6. open database.php and put database name, username, password

  7. open config.php and set the base url to whatever project folder you are currently working on like $config['base_url'] = 'http://localhost/CodeIgniter'; then, remove the index.php from $config['index_page'] = ''; . Add an encryption key for sessions in $config['encryption_key'] = ''; . Change the existing config settings to

    $config['sess_driver'] = 'database';
    $config['sess_table_name'] = 'ci_session';
    $config['sess_expiration'] = 7200;
    $config['sess_encrypt_cookie'] = TRUE;
    $config['sess_cookie_name'] = 'ci_session';
    $config['sess_match_ip'] = FALSE;
    $config['sess_time_to_update'] = 300;
    $config['sess_match_useragent'] = FALSE;
  8. open routes.php and set default_controller $route['default_controller'] = 'def_cont';

  9. Execute following SQL

    CREATE TABLE IF NOT EXISTS `ci_session` (
            `id` varchar(128) NOT NULL,
            `ip_address` varchar(45) NOT NULL,
            `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
            `data` blob NOT NULL,
            KEY `ci_sessions_timestamp` (`timestamp`)
    );

to be continued...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment