1

When I upload my fully working codeigniter app on live server it did not find any controller and cotroller action.

For example:

my local url is:

localhost/myapp/index.php/testcontroller/testaction

Yes, It works fine, But when I upload the same thing and url becomes:

livesite.com/index.php/testcontroller/testaction

It does not work. Shows error that cant fine the controller. I am wondering why it is happening so while it is working on local server.

controller code:

<?php
class Ajaxification extends CI_Controller{
    public function __construct() {
        parent::__construct();
        $this->load->database();$this->load->model('MAjaxification');
    }
    public function Index(){
        
    }
    public function getUserDetail(){
        $this->load->model('MAjaxification');
        $uid = $_REQUEST['uid'];
        echo $this->MAjaxification->getUserdetail($uid);
       // echo "A test response";
    }
    public function getRandomUser(){
       $top = $_REQUEST['top'];
       $left = $_REQUEST['lef'];
      // $this->load->model('MAjaxification');
     //  print_r($this->MAjaxification->getRandomDonoers());*/
        $this->db->select("users.sno,users.full_name,users.userid,users.email,users.pic");
        $this->db->from('users');
        $this->db->join('donors','users.userid=donors.userid');
        $this->db->order_by('rand()');
        $this->db->limit(51);
        $res= $this->db->get();

        foreach ($res->result() as $row)
        {
          ?> <div style="border:0px solid black; width: 31px; height: 29px; float: left;">
        <a onclick="getUserinfoDetail('<?=$row->userid?>')" href="javascript:void(0)"><img width="40" height="40" src="../profile_pix/<?=$row->pic; ?>" /></a>
    </div><?php
        }
        
    }

    private function countUsers(){
        $this->db->select("users.sno,users.pic");
        $this->db->from('users');
        $this->db->join('donors','users.userid=donors.userid');
        $res = $this->db->get();
        return $res->num_rows();
    }
    function getRandUser($f=1,$t){
       $index = rand($f, $t);
       return $index;
    }
    public function testme(){
        echo "This is a test";
    }
}
?>
11
  • Can you provide us with link to site? It might be misconfigured install or are you sure you have uploaded all files? Commented Oct 1, 2011 at 9:01
  • dustyfeet.designers99.com/index.php/ajaxification/testme You can see that dustyfeet.designers99.com is working my base_url is: $config['base_url'] = 'dustyfeet.designers99.com'; Commented Oct 1, 2011 at 9:10
  • Other Controllers looks like work, are you sure there is this controller? Please paste the code of that controller please? Commented Oct 1, 2011 at 9:16
  • Yes, it is working on my local server Commented Oct 1, 2011 at 9:18
  • All controller code is not possible in this comment Commented Oct 1, 2011 at 9:19

3 Answers 3

2

I never worked with Codeigniter, but if it is similar to Kohana, you have to setup the base_url. [EDIT] Check this post from CodeIgniter forum: https://github.com/EllisLab/CodeIgniter/wiki/Automatic-configbase-url

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

Comments

1

I think this problem may be related to some configs in application config folder routes.php :

  • $route['default_controller'] you should be set it to the default controller

    config.php :

  • $config['base_url'] should be '' if you used the htaccess rules to remove index.php in the URL and also the .htaccess file in the app directory may be causing this problem

Also the controller filename must be the same name of the class which extends the CI_Controller

Comments

1

In config.php add base_url like this; this will automatically get URL:

$base = "http://".$_SERVER['HTTP_HOST']; $base .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

$config['base_url'] = $base;

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.