I am using the routing system AltoRouter , and its use is quite simple, use this way:
**** THIS IS INDEX.PHP *****
/*Incluo o arquivo do AltoRouter*/
include ('application/router.php');
$router = new AltoRouter();
$router -> setBasePath('/mvc/'); ** aqui é o diretório base **
$router -> map('GET', 'noticia', 'noticia#index', 'noticia');
$match = $router -> match();
**Aqui a estrutura da chamada controlller#action no padrão MVC**
if ($match === false) {
header('Location: /mvc/error');
} else {
list($controller, $action) = explode('#', $match['target']);
if (is_callable(array($controller, $action))) {
$obj = new $controller;
call_user_func_array(array($obj, $action), $match['params']);
} else {
exit('O Controller não pôde ser chamado');
}
}
the .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
The problem is that when calling a view through the VIEW class (where the frontEnd files are called) ... the frontEnd part directory (css, js and images) is not recognized, the system thinks it is a controller, example:
<link rel="stylesheet" href="public/main.css">
The page can not find the file / directory (public / main.css) and is redirected to the error page as defined in the above code.
I do not understand much about regular expressions, but I think that's it, how can I solve it?