friendly url with several paramters in htaccess

2

I see that some sites like olx, buscape among others, when sent several parameters in the url are separated these parameters by / or -.

For example: link

Do I need help removing the? and & and sort by /.

Example:

site.com.br/imovel?id=3366

Leave it this way:

site.com.br/imovel/3366

My htaccess is configured this way but is not working:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([a-z0-9\-]+)$ index.php?pagina=$1 [QSA]
RewriteRule ^exclusive/imovel/(\d+)$ imovel?id=$1 [QSA]
RewriteRule ^exclusive/lista/(\d+)$ lista?id=$1 [QSA]

I'm using php and the function to manipulate the url looks like this:

function getHome(){
        $url = $_GET['pagina'];
        $url = explode('/', $url);
        $url[0] = ($url[0] == NULL ? 'content' : $url[0]);


        if(file_exists('tpl/'.$url[0].'.php')){
            require_once('tpl/'.$url[0].'.php');
        }elseif(file_exists('/tpl/'.$url[0].'/'.$url[1].'.php')){
            require_once('tpl/'.$url[0].'/'.$url[1].'.php');
        }elseif(file_exists('/tpl/'.$url[0].'/'.$url[1].'/'.$url[2].'.php')){
            require_once('tpl/'.$url[0].'/'.$url[1].'/'.$url[2].'.php');
        }else{
            require_once('tpl/404.php');
        }
    
asked by anonymous 25.09.2015 / 22:13

1 answer

2

Replace the last three lines with RewriteRule. * index.php

Then manipulate the contents of $ _SERVER ['REQUEST_URI'].

    
26.09.2015 / 05:36