2

I am using codeigniter 3.

I created login controller like

<?php
class Login extends CI_Controller
{
     public function index()
     {
          echo "It's working";
     }
}
?>

My .htaccess file

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

I also enabled rewrite module.

It is working on

http://localhost/codeigniter/index.php/login

but not on

http://localhost/codeigniter/login

How can I solve this issue. or its bug in codeigniter 3.0.4 Please help.

Jatin Raikwar
  • 406
  • 5
  • 17

5 Answers5

3

Your mod_rewrite rules are redirecting to /index.php instead of /codeigniter/index.php.

Put this in your .htaccess file:

RewriteBase /codeigniter/
Narf
  • 14,600
  • 3
  • 37
  • 66
1

if this is still not working, you might want to check you httpd conf to make sure Override for .htaccess is allowed because AllowOverride controls what directives may be placed in .htaccess files. Invariably, if you place settings in the .htaccess file and you do not AllowOverride for those settings, the dafault Apache settings would still run and everything in your .htaccess would not be used. For example

<VirtualHost *:80> 
  ServerName application.co

  DocumentRoot "/Users/www/htdocs/application/"
  ErrorLog "/Users/www/logs/application_error.log"



  <Directory "/Users/www/htdocs/application/" >
      DirectoryIndex index.php index.html
      Order allow,deny
      Allow from all
      Allow from localhost, application.co
      Require all granted
      AllowOverride All
   </Directory>
 </VirtualHost>
Precious George
  • 105
  • 4
  • 8
0

change

$config['index_page'] = 'index.php';

to

$config['index_page'] = '';

in config/config.php

Zohaib
  • 588
  • 1
  • 6
  • 23
0

Open config.php and do following replaces

$config['index_page'] = "index.php"

to

$config['index_page'] = ""

In some cases the default setting for uri_protocol does not work properly. Just replace

$config['uri_protocol'] ="AUTO"

by

$config['uri_protocol'] = "REQUEST_URI"

HTACCESS

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

You can try this htaccess i use on xampp.

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

Place in main directory of project.

And on config.php

$config['base_url'] = 'http://localhost/your_project/';

$config['index_page'] = '';

And make sure your class and file names have first letter upper case as explained here.

Also for more htaccess Here