php - Codeigniter version 2.0.2 redirect loop issue


I have moved from codeigniter 1.7 to 2.0 and so i replaced MY_Controller to CI_Controller andparent::MY_Controller(); toparent::__construct(); in login controller and from login controller view is loading and in that view I have added exit at start of the file its not a problem occurring due to other files.

Now, by this change my error for controller has gone, but the issue is I am having error for redirect loop.

If I have added exit beforeparent::__construct(); then it is working fine,but If i have added exit afterparent::__construct();,its going to redirect loop.

There is nothing writter in my hook.php

My route php is 

$route['default_controller'] = "login";
$route["404_override"] = "";

 Codigniter version is 2.0.2



 class Login extends CI_Controller

 function __construct()

{ echo "test";exit // Here,its working fine without going to loop


    echo "test";exit // Here this will give redirect loop issue 




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

 // route.php

 $route['default_controller'] = "login";
 $route["404_override"] = "";



Is your server shared or dedicated ?

If it is shared,then make sure that mod_rewrite is enabled on server otherwise it won't recognize htaccess file you have added and that may be the reason for redirect loop issue.

Please ask your hosting provider to make it enable (If it is disabled on shared server) and check !!

People are also looking for solutions to the problem: php - Search results not showing


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.