Yaniiick
Yaniiick

Reputation: 53

Removing index.php from CodeIgniter URL

I'm struggling with removing the 'index.php' part of my CodeIgniter URL. I'm using CodeIgniter version 3.1.2. I've followed all steps on other questions about this:

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

However when I try to access my site, I get the following error code.

Not Found

The requested URL /Toneel/Site/index was not found on this server.

The rewrite module is turned on in my Apache Server. Can anyone help me out with this issue?

Upvotes: 2

Views: 3271

Answers (4)

Jean Manzo
Jean Manzo

Reputation: 123

In my case, it works with:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /project-name

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

** Important, this should be in an .htaccess file in the root of your project.

In config should be like this:

$config['base_url'] = 'http://your-url-here/';
$config['index_page'] = '';

Upvotes: 0

coderszx
coderszx

Reputation: 327

Try this in your .htaccess file

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

Upvotes: 0

rango
rango

Reputation: 629

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.

Upvotes: 4

Pathik Vejani
Pathik Vejani

Reputation: 4501

Try this code in .htaacess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]

Upvotes: 1

Related Questions