How To redirect in codeigniter Examples

Today, We want to share with you How To redirect in codeigniter Examples.In this post we will show you codeigniter redirect refresh, hear for call to undefined function redirect() we will give you demo and example for implement.In this post, we will learn about How To Open URL In New Tab Using CodeIgniter with an example.

How To redirect in codeigniter Examples

There are the Following The simple About codeigniter redirect to homepage Full Information With Example and source code.

As I will cover this Post with live Working example to develop redirects in codeigniter using base_url, so the redirects to external url in codeigniter is used for this example is following below.

how to redirect to another page in codeigniter?
In codeigniter, there are a few ways to redirect to another page.

The simplest way is to use the 301 redirect feature. This will automatically create a new page with the requested URL and set the HTTP status to 301 (Moved Permanently).

Another way is to use the Redirect action. This will create a new action in your controller with the requested URL. This can then be used to call a function or script that will redirect the user to the new page.

You can also use the redirect_to function. This will create a new route in your app and will redirect the user to the new page.

CodeIgniter – Page Redirection

How To redirect in codeigniter Examples
How To redirect in codeigniter Examples

While building PHP Based codeigniter User Friendly web application, I always required to open new tabe redirect the any other from one page to another page with parameters. here PHP Based CodeIgniter creates this task with demo easy for us. The codeigniter redirect() methods is used for this best solution for us.

Step 1: Create a codeigniter controller


      public function product_list() { 
      public function estores() { 

Step 2: Change the routes in codeigniter


$route['redirect'] = 'Product_controller'; 
$route['redirect/estores'] = 'Product_controller/estores'; 
$route['redirect/product_list'] = 'Product_controller/product_list';

Step 3: run in Browsers

CodeIgniter redirect: white page


//using Refresh

//using and location:
header("Location: ".$uri, TRUE, $http_response_code);

redirect in codeigniter using base_url

CodeIgniter: Passing some data along with the redirect

redirect('/signin/form/', 'refresh');

$this->session->set_flashdata('products', 'products_value');
$message = $this->session->flashdata('products');

here full example of the Pass Data From CodeIgniter Controller to View page

Make a View




Welcome to WordPress

Load the View


controller -> WordPress.php


Pass array from controller to view

$data['mega_header'][] = (object) array('seo_title_part' => 'Welcome To Pakainfo' ,
    'img' => '' );
$this->load->view('multiple_array', $data);

view file

<?php echo($key['seo_title_part']); ?>

Load Multiple Views

        $this->load->view('content', $data);

Sort Views in Subfolders


Add Dynamic Data to Views

$data = array(
    'seo_title_part' => 'Online Development and Testing Tools',
    'title_h1_part' => 'Pakainfo - Online Educational Computer Programming website',
    'message' => ' Pakainfo helps build web applications,tutorials,programming,examples,source code,demos,tips.It is an educational blog for learning web technologies online.'
$this->load->view('shoplistweb', $data);

in controller

load->view('shoplistweb', $data);

the view file

    <?php echo $seo_title_part;?>

Make the Loops

load->view('shoplistweb', $data);

the view file

    <?php echo $seo_title_part;?>

Returning View as Data

$string = $this->load->view('fileview', '', TRUE);
Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about redirects with success message in codeigniter.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment