CodeIgniter Page Redirection - CodeIgniter

What is CodeIgniter Page redirection?

While building internet software, we regularly need to redirect the consumer from one page to another web page. CodeIgniter makes this job clean for us. The redirect () function is used for this reason.


redirect($uri = '', $method = 'auto', $code = NULL)


· $uri(string) − URI string

· $method(string) − Redirect method (‘auto’, ‘location’ or ‘refresh’)

· $code(string) − HTTP Response code (usually 302 or 303)

Return type


The primary argument may have two styles of URI. We are able to pass whole web page URL or URI segments to the controller you want to direct.

The second optional parameter will have any of the 3 values from auto, location or refresh. The default is auto.
The third optionally available parameter is best to be had with location redirects and it allows you to send specific HTTP response code.


Create a controller called Redirect_controller.php and save it in application/controller/Redirect_controller.php

Alter the routes.php file in application/config/routes.php to add route for the overhead controller and add the following line at the end of the file.

Type the following URL in the browser, to execute the example.

The above URL will redirect you to the website and if you visit the following URL, then it will redirect you to the computer graphics tutorial at

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

CodeIgniter Topics