I need help with this problem, I have the following code
<?php
include 'modules/head.php';
/**Contenido de pagina */
$rutas = array();
if(isset($_GET["ruta"])){
$rutas = explode("/",$_GET["ruta"]);
$rutaCategoria = CategoriaController::CtrlCategorias($rutas[0]);
if($rutas[0]==$rutaCategoria){
echo 'pagina categoria';
}else{
include 'modules/404page.php';
echo $rutaCategoria;
}
}
if (isset($_GET["ruta"])==false) {
include 'modules/inicio.php';
}
/**Fin de contenido de pagina */
include 'modules/footer.php';
?>
where $ routes only takes the first parameter to look for it in a white list of categories that comes from a controller that brings it from a database.
I could use another conditional for the detail of each product but I would stay in the first parameter, as I could keep the first parameter and take the second parameter for the product detail in such a way that when entering a product the url would look like this:
domain.com/category/product
obviously each product in the database has a category assigned to it.
my .htaccess has this configuration:
# impedir que se pueda ver el listado de contenidos de un directorio
Options All -Indexes
# url amigables
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([-a-zA-Z0-9]+)$ index.php?ruta=$1