4

I am a newbie at codeigniter. I have my codeigniter installed at localhost/path/learn_ci.

I have followed all the steps given in the codeigniter wiki. Here is my .htaccess file.

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

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

I've also changed the config file as required. But when I try to access

I get this error

"The requested URL /learn_ci/index.php/welcome was not found on this server"

I have double checked...the mod_rewrite module in Apache is on.

The RewriteBase solution also didn't work. Am I doing something wrong??

punitjajodia
  • 92
  • 1
  • 7

6 Answers6

2

As others have said, make sure that AllowOverride is set to All in your apache config or your virtual host file. Given the path that you have codeigniter setup in, your htaccess should look like this:

RewriteEngine On
RewriteBase /path/learn_ci

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

Also, remember that any assets you are using (img, css, js, etc) are referenced either with the base_url() function or using relative paths. The root of your project is going to be /path/learn_ci.

I find that it is easier to create a virtual host and add an entry to my hosts file locally. This mimics real life much better.

  • Exact and complete answer (b)http://stackoverflow.com/questions/14297770/cannot-remove-index-php-from-codeigniter-url(/b) – Sami Sep 22 '13 at 07:50
1

Try:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]  
Sudhir Bastakoti
  • 94,682
  • 14
  • 145
  • 149
1

You can do the following:

First in config.php file set

$config['index_page'] = '';

Next, create a .htaccess file in the codeigniter root folder and add the following content:

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

Save the file. It should work.

Dibyendu Mitra Roy
  • 1,294
  • 16
  • 17
0

You place the htaccess file in your root public_html folder in the same directory as index.php

Then remove /learn_ci from your htaccess file, just make it /index.php/$1

Laurence
  • 55,427
  • 18
  • 158
  • 197
0

Check your apache config, it should be something like :

Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
greenLizard
  • 2,230
  • 5
  • 23
  • 30
0

I thought to add my answere. My project base url is http://localhost/newproject/ I included htacess file in the newproject folder.

here is the code.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L,QSA]

then I change config file.

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

and every thing started to work. now nomore index.php file.

newday
  • 3,550
  • 9
  • 46
  • 76