I'm with a project using the model-view-controller and I want to make the url "friendly". For this I want to change part of the url to rewrite the part of the url that puts /? Zone = menu-javascript and leave me alone / menu-javascript.
I understand that I have to do this through a .htacces file. This file I have and has this code:
#Activar RewriteEngine
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#Reescribir la URL solicitada por el usuario
#Entrada: seccion partiendo desde raiz
#Salida: ?zona=seccion
RewriteRule ^([a-zAZ0-9]+)$ ?zona=$1
ErrorDocument 404 /
I make the request to each zone in the following way:
<?php
session_start();
$componente = (isset($_GET['zona'])) ? $_GET['zona'] : 'home';
function loader($componente) {
ob_start();
include 'componentes/' . $componente . '/controller.php';
$buffer = ob_get_clean();
return $buffer;
}
I think the pattern is correct but it does not work for me. Any suggestions? Thanks.