we often need to redirect the user from one page to another page. The redirect() function is used for this purpose. it is used to "header redirect" to the specified URL.
Note : $this->load->helper('url'); // URL helper must be loaded before redirect() function used.
The first argument can have two types of URI. We can pass full site URL or URI segments to the controller you want to direct.
The second optional parameter can have any of the three values from auto, location or refresh. The default is auto.
The third optional parameter is only available 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
Change the routes.php file in application/config/routes.php to add route for the above controller and add the following line at the end of the file.
$route['redirect'] = 'ittutorial_controller';
$route['redirect/show'] = 'ittutorial_controller/show';
$route['redirect/showlist'] = 'ittutorial_controller/showlist';
Type the following URL in the browser, to execute the example.
http://itttutorial.in/index.php/redirect
The above URL will redirect you to the itechtuto.com website and if you visit the following URL, then it will redirect you to the computer graphics tutorial at itechtuto.com.
http://itttutorial.com/index.php/redirect/showlist
How to redirect url in codeigniter?
How to redirect url in codeigniter?
Trending Tutorials