How to redirect a search result page (/ search? term = brazil) to another page (/ country / brazil)

0

I'm putting together a revenue site that has a search which is a form with GET method and query MYSQL to bring the results.

I would like that when someone does a specific search, for example Brazil, it goes to a specific page that has already been created, eg: / search? term = brazil, it will be redirected to /

What is the best way to do this?

    
asked by anonymous 03.09.2018 / 01:22

1 answer

-1

I found the solution: link

When doing the search it verifies the term that was searched, there if it is the same as the one that predefini, it directs:

Search:

echo'
<form method="get" action="/busca">
<input type="text" name="termo" placeholder="Procure por receita ou ingrediente...">
<button name="submit" type="submit" >Procurar</button>
</form>';
include($_SERVER['DOCUMENT_ROOT'].'/busca-receitas/direciona.php');

Do a "pre-query" before bringing the result

<?php
if(isset($_GET['submit'])){
$name = $_GET['termo'];
if($termo =='brasil'){       header("Location:http://componente.pratodoprato.com.br/pais/brasil");
}else{
header("Location:http://componente.pratodoprato.com.br/busca?termo=cebola");
}
}
?>
    
03.09.2018 / 01:52