codeigniter

Removing index.php using WAMP and CodeIgniter

How to remove the index.php from url’s with using wamp and codeigniter

First thing to do is enable the mod rewrite on wamp go to Apache modules and scroll down the list

If not showing tick enable it and then restart all servers.

enter image description here

Linux users can also use below terminal command to enable rewrite module

sudo a2enmod rewrite

Then restart apache using:

sudo service apache2 restart

Then out side of your application folder create a file called .htaccess

project > application

project > system

project > .htaccess

project > index.php

Try this code below

Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]

If not here is some more htaccess examples

Then go to the config.php file. Set your base_url and make the index_page blank

    $config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
    $config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
    $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
    $config['index_page'] = '';

Hope this helps you can use the htaccess files from examples for others.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow