Download and extract codeigniter. In main folder create another folder named assets. There will be additional files for css, js and more.
Setup configuration files. Go to application/config:
– in autoload.php
$autoload['libraries'] = array('database','session'); |
|
$autoload['helper'] = array('url','form'); |
– in config.php
$config['base_url'] = 'http://www.example.com/'; |
|
$config['index_page'] = ''; |
|
$config['encryption_key'] = 'someEncryptionKey'; |
|
$config['sess_save_path'] = sys_get_temp_dir(); //Fix problems with session |
– in database.php
'username' => 'root', |
|
'password' => 'rootPassword', |
|
'database' => 'DatabaseName', |
– in routes.php
$route['default_controller'] = 'Main_controller'; |
Step 2 Create Main_controller file in application/controllers
Easiest way is to copy and rename Welcome.php
Step 3 Create .htaccess file in main folder. This is a must for routing!
RewriteEngine On |
|
|
|
RewriteCond %{HTTP_HOST} ^my-domain.com [NC] |
|
RewriteRule ^(.*)$ http://www.my-domain.com/$1 [L,R=301] |
|
|
|
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/ |
|
RewriteRule ^index\.php(/(.*))?$ http://www.my-domain.com/$2 [R=301,L] |
|
|
|
RewriteCond %{REQUEST_FILENAME} !-f |
|
RewriteCond %{REQUEST_FILENAME} !-d |
|
RewriteRule ^(.*)$ index.php?/$1 [L] |