Problem: The default URL for Codeigniter contains index.php in it. How to remove that from URL?
For example: How do we change
http://localhost/workspace/pagination_demo/index.php/Home/ to http://localhost/workspace/pagination_demo/Home/
Solution:
Steps:
1. Go to application- config folder inside your project:
$config['index_page'] = 'index.php';
replace it with
$config['index_page'] = '';
3.In the root directory of the project(parallel to application folder).
Add a new file named .htaccess.
Add following content to the file:
RewriteEngine On RewriteBase /workspace/pagination_demo/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteBase property specifies the name of project inside document root.
This location is relative to the document root.
4.Now go to /etc/apache2/sites-enabled/000-default file.
change AllowOverride None to AllowOverride All to allow apache to override url’s: