Ashutosh Mishra
Ashutosh Mishra

Reputation: 407

Remove index.php in codeigniter

I know it is the most repetitive question of CI.

I am using Kubuntu and have made following changes

$config['base_url']='http://localhost/cii/';
$config['index_page'] = '';
$config['uri_protocol']= 'REQUEST_URI';

I've kept my .htaccess file where index.php is kept (in the root folder) but am getting following error:

The requested URL /cii/welcome/second was not found on this server.(404 error)

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|robots\.txt|css)
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule> 

<IfModule !mod_rewrite.c>
     ErrorDocument 404 /index.php
</IfModule>

Upvotes: 2

Views: 318

Answers (2)

Paulraj
Paulraj

Reputation: 3397

Possibly the problem is due to the AllowOverride None of document root path in apache sites-available configuration file. You need to modify the line containing AllowOverride None to read AllowOverride All in the file (/etc/apache2/sites-available/default) to make .htaccess files work as expected. Do restart apache once after made the changes.

    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

Enabling use of Apache htaccess files.

Upvotes: 2

splitfeed
splitfeed

Reputation: 94

I would guess that the error is because your CI is located at the subfolder /cii but the rewrite rules point to the root folder. Try adding RewriteBase /cii/ inside the first block.

Upvotes: 0

Related Questions