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
LOGIN FILE ::
/public_html/projectname/application/controller/login.php
class Login extends CI_Controller
{
function __construct()
{ echo "test";exit // Here,its working fine without going to loop
parent::__construct();
echo "test";exit // Here this will give redirect loop issue
}
}
/public_html/projectname/.htaccess
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"] = "";
Answer
Solution:
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 !!