2
i see that some sites like olx, search among others, when sent several parameters in the url is separated these parameters by / or -.
For example: http://sc.olx.com.br/norte-de-santa-catarina/imoveis/casas-a-partir-de-450-00-reais-118704544
I need help eliminating ? and & and separating by /.
Example:
site.com.br/imovel? id=3366
Leave that way:
site.com.br/imovel/3366
My htaccess is configured this way but 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 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');
}
I believe your problem is not in htaccess. The problem is how your application interprets the named urls.
– Rubico
Igor, your application was developed in what language? Are you using any framework?
– Rubico
I’m using php, but no Framework.
– Igor Silva
I edited the question.
– Igor Silva