-2
I set up my .htaccess to use the URL Amigáveis on the site I’m developing, but I’m having a hard time passing and receiving parameters, by the rule that defines everything that is entered in the URL is going through my index, when I don’t have parameters the page being called is displayed correctly but when I try to pass a parameters to a page it falls in the exception of mine IF and goes to the page 404 because the script understands that it is a page and that page does not exist.
For example:
My . htaccess:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
Options -Indexes
RewriteRule ^(.*)$ index.php?url=$1 [NC]
#RewriteRule ^([^/]+)/?$ projeto.php?id=$1 [L,QSA]
By calling the page about us
<a target="_blank" href="sobre-nos">NOSSA HISTÓRIA</a>
In my index.php the script is like this:
$rotaURL = (isset($_GET['url'])) ? $_GET['url']:'home';
$rotaURL = array_filter(explode('/', $rotaURL));
$pagina = $rotaURL[0].'.php';
if(is_file($pagina)){
include("inc-topbar.php");
include("inc-cabecalho.php");
// INCLUI SLIDER SE FOR A PÁGINA PRINCIPAL
if ($pagina == 'home.php') {
include("inc-slider.php");
}
include($pagina);
} else {
include("inc-topbar.php");
include("inc-cabecalho.php");
include '404.php';
}
The About Us page is displayed correctly, but if I try to call the Water Eye Project page in this way, it is not recognized and falls into the 404.
<a target="_blank" href="projeto/1">PROJETO OLHO D´AGUA</a>
The second rule of my . htaccess is like this:
RewriteRule ^([^/]+)/?$ projeto.php?id=$1 [L,QSA]
I also tried to retrieve the variables for verification, that way:
if (isset($_GET['id')) {
// AÇÃO DE ACORDO COM O PARÂMETRO
}
I understand that the rule is configured incorrectly, but I have tried many alternatives that I found in my research and all did not work.