How to modify a url sent by form via get [Codeigniter]?

0

Personal I need to modify a url but I do not know how to do this. I have the following url:

http://wedding.axitech.com.br/?procuraonde=Palhoça&procuraoque=bolos

I need to make the url below:

http://wedding.axitech.com.br/palhoca/bolos

Can someone help me to get this result in Codeigniter ?

    
asked by anonymous 07.08.2016 / 20:41

1 answer

2

You can create a route where the segments will become the get parameters for the method of a controller or enter in the url the name of the controller and the desired method in the first and second segments respectively of the url. Segment is each value passed between the url bars counting from the url base of the site. The sequence is: url_base/controlador_ci/metodo_do_controlador/parametro1/paramentro2/ ... Where controlador_ci is the first segment, metodo_do_controlador the second segment, and so on. Here is an example of what the url you want with the route would look like.

url: http://wedding.axitech.com.br/buscar/palhoca/bolos

access the file application/config/routes.php and create the $route['buscar'] = 'Busca/efetua_busca'; route;

create the following driver:

Controller

public class Busca extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function efetua_busca($onde, $oque) {
        /* $onde receberá palhoca e $oque receberá bolos. 
           A sequência é a mesma que passada na url */

        echo $onde; // imprime palhoca
        echo $oque; // imprime bolos
    }
}
    
08.08.2016 / 00:04