1

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:
http://localhost/training/belajaradmin/
and it working just fine. As well for this URL
http://localhost/training/belajaradmin/index.php/login

But, when I put this URL as I remove the index.php:
http://localhost/training/belajaradmin/login
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";
Muhammad Saifullah
  • 87
  • 1
  • 3
  • 15

2 Answers2

3

In .htaccess add following line after RewriteEngine on

RewriteBase    /training/belajaradmin/

Edit config as follows:

$config['base_url'] = ''; 
$config['index_page'] = '';
0

Activate the mod_rewrite module

sudo a2enmod rewrite

Restart apache

sudo service apache2 restart
MurthyAdapa
  • 121
  • 5
  • For windows please follow the steps given here - https://webdevdoor.com/php/mod_rewrite-windows-apache-url-rewriting – MurthyAdapa Nov 08 '16 at 09:41