How to Remove 'Index.Php' from Url in Codeigniter

Remove index.php from url in CodeIgniter 3

Update your htaccess file with the below code

RewriteEngine On
RewriteBase /demo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

and in config file, please change base url with below code:-

$root  = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;

How to remove index.php in codeigniter's path

If you are using Apache place a .htaccess file in your root web directory containing the following:

RewriteEngine on
RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Another good version is located here:

http://snipplr.com/view/5966/codeigniter-htaccess/

Removing index.php from CodeIgniter URL

This setting worked for me.

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>

To allow overriding htaccess in Apache Configuration you have to edit and change /apache2.conf file to

AllowOverride All

And restart server.

CodeIgniter removing index.php from URL not working

You don't have to edit index.php, replace the content .htaccess file to:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Codeigniter 3.1.6 - How to remove index.php from url

Change folder name CodeIgniter-3.1.6 to ci

Set your base_url to

$config['base_url'] = 'http://localhost/ci/

Use this .htaccess

RewriteEngine On
RewriteBase /ci
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

While removing index.php from url in codeigniter, i am getting following error .Not Found The requested URL was not found on this server

Codeigniter 4 have two different .htaccess files, you need to change the one in public folder:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]


Related Topics



Leave a reply



Submit