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";
3
  • RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] Commented Nov 8, 2016 at 9:10
  • I did that but it does not work Commented Nov 8, 2016 at 9:19
  • Possible duplicate of CodeIgniter removing index.php from url Commented Nov 8, 2016 at 9:30

2 Answers 2

3

In .htaccess add following line after RewriteEngine on

RewriteBase    /training/belajaradmin/

Edit config as follows:

$config['base_url'] = ''; 
$config['index_page'] = '';
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! it does working now like a charm. I just edit .htaccess file and then it work like I want. As for the config.php I did not make the changes as you suggest as my css look different.
happy coding :)
0

Activate the mod_rewrite module

sudo a2enmod rewrite

Restart apache

sudo service apache2 restart

1 Comment

For windows please follow the steps given here - webdevdoor.com/php/mod_rewrite-windows-apache-url-rewriting

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.