dpzbh1779 2015-03-12 07:00
浏览 62
已采纳

Codeigniter版本2.0.2重定向循环问题

I have moved from codeigniter 1.7 to 2.0 and so i replaced MY_Controller to CI_Controller and parent::MY_Controller(); to parent::__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 before parent::__construct(); then it is working fine,but If i have added exit after parent::__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"] = "";
  • 写回答

1条回答 默认 最新

  • doudong8713 2015-03-13 05:29
    关注

    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 !!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题