I use redirect() (from uri helper) in every function who need to load the main view of my app. It redirect to the same function. My goal is to get the same clean uri, even when i use a pages' feature (that call other controller). Is it good practice? When should i use redirect()? Are there any other solution to get a similar result?
this is some code to clarify.
Here is a controller :
<?php
class Main_controller extends Controller
{
function index()
{
$this->load->view(page);
}
function page_feature()
{
/* some stuff */
redirect('main_controller.php','refresh');
}
}
With this route rules :
$route['([a-z-A-Z1-9_]+)'] = "main_controller";
The uri is like this : myapp.com/something On this page, there are feature who calls (on submit) other functions of main_controller ( or other controller), like a form for example:
<form action="myapp.com/another_controller/method" method="post">
at the end of this query "/another_controller/method", i use redirect('main_controller') to display the view with the new data, and keep the uri "myapp.com/something" instead of "myapp.com/another_controller/method".
I wanted to know if this is good or bad practice, and why.