Muhammad Saifullah Muhammad Saifullah - 1 year ago 109
PHP Question

Removing index.php using codeigniter 2

I want to remove the 'index.php' link from the url project folder but it return error 404 Page Not Found.

My default URL is:


and it working just fine. As well for this URL


But, when I put this URL as I remove the index.php:

The code does not work.
Im using codeigniter 2.2.6. The code below is the name of the file and the changes that I have made.

.htaccess at root

RewriteEngine on
RewriteCond $1 !&(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

config.php in 'application' folder

$config['base_url'] = 'http://localhost/training/belajaradmin/';
$config['index_page'] = '';

autoload.php in 'application' folder

$autoload['helper'] = array('url');

routes.php in 'application' folder

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

Answer Source

In .htaccess add following line after RewriteEngine on

RewriteBase    /training/belajaradmin/

Edit config as follows:

$config['base_url'] = ''; 
$config['index_page'] = '';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download