0
I’m using the routing system Altorouter, and its use is very simple, use this way:
**** THIS IS THE 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');
}
}
o File . htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
The problem is that when calling a view by class VIEW (where it has the call of the frontend files)... the directory of the frontend part (css, js and images) is not recognized, the system thinks it is a controller, example:
<link rel="stylesheet" href="public/main.css">
The page cannot locate the file/directory (public/main.css) and is redirected to the error page as defined in the above code.
I don’t know much about regular expressions, but I think this is it, how can I solve?