Codeigniter redirect does not working right

1092 views php

I've already tried the other codeigniter redirect not working topics, but they have different issues than mine.

It throws this kind of error.

This is the one where I put my redirect.

defined('BASEPATH') OR exit('No direct script access allowed');

class SampleView extends CI_Controller {

public function index() {

    $data['title'] = 'Home';

    $this->load->view('includes/header', $data);


public function update() {

    $data = array(
        'item_id' => $this->input->post('i_id', true),
        'item_name' => $this->input->post('i_name', true),
        'item_price' => $this->input->post('i_price', true),
        'item_description' => $this->input->post('i_description', true),


This is the form that will link to update function.

<form method="POST" action="<?=$this->config->base_url();?>sampleview/update">

This is my config.php

$config['base_url'] = 'http://localhost/w31_ton';

And this is my htaccess.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /w31_ton

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

PS. It all works fine, my only problem is that it won't redirect to the page I want.

answered question

1 Answer


You have to load URL helper file before calling redirect() function for the redirect to work. Inside update function, add - $this->load->helper('url'); . That should fix that.

posted this

Have an answer?


Please login first before posting an answer.