I want to access my URL\'s without index.php
in CodeIgniter. Here is my Blog
controller
class Blog extends CI_Controller {
pub
I just now struggled with this part again, even after being used to Codeigniter for 2+ years.
None of the answers helped me exactly, including the official Codeigniter's page about this, so I'm posting the solution that worked for me.
Enable Rewrite engine
sudo a2enmod rewrite
Change Apache's config file to allow folders to allow overriding of default security setting
sudo nano /etc/apache2/apache2.conf
Under the "Directory" options depending on the location of your files, edit
AllowOverride None
to
AllowOverride All
e.g.: My server files are in "/var/www", so my final result for corresponding Directory options is:
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
In the file, put the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
In config/config.php file, change:
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';
Restart apache2:
sudo service apache2 restart
Enjoy!