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.

6
  • What localhost you using xampp, wamp? Commented Mar 12, 2016 at 7:09
  • On your config.php have you made this like so $config['index_page'] = ''; Commented Mar 12, 2016 at 7:12
  • @wolfgang1983 xampp , in config.php I have $config['index_page'] = 'index.php'; Commented Mar 12, 2016 at 7:13
  • try this config!!! stackoverflow.com/questions/2171185/… Commented Mar 12, 2016 at 8:35
  • @AldoZumaran Got this error Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. If you think this is a server error, please contact the webmaster. Error 404 localhost Commented Mar 12, 2016 at 8:42

5 Answers 5

3

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

Put this in your .htaccess file:

RewriteBase /codeigniter/
Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

0

change

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

to

$config['index_page'] = '';

in config/config.php

6 Comments

thanks for answer I tried $config['index_page'] = ''; but not working
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] try it in htaccess in place of RewriteRule ^(.*)$ index.php/$1 [L]
are you use server in linux? mean xampp or wamp ?
I am using windows 7 and xampp, @ZohaibHassan its not working
have you restart xampp after enabling rewrite_module??
|
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] 

4 Comments

are you replace .htaccess with this bcz its worked for me
Ya I did but not working, is it a bug in codeigniter? @MayankVadiya
No not a bug. What is your url
@MayankVadiya there is no AUTO in CI3 uri_protocol
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.