Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

280
Vistas
PHP routing system altorouter not working

I'm just developing a website with PHP and for routing, I decided not to build the whole system myself anymore, then I chose altorouter/altorouter. So here's my site tree my site tree

And here's what my index.php looks like

<?php

define('WEBROOT', __DIR__);

define('TARGET_PATH', WEBROOT.'/contents');


require 'vendor/autoload.php';

$router = new AltoRouter();

$router->setBasePath('/kpitalis.com/');

require_once 'config/routes.php';

$match = $router->match();

$target = $match['target'];
$params = $match['params'];


if (is_array($match)) {
    if (is_callable($match['target'])) {
        call_user_func_array($target, $params);
    } else {
        ob_start();
        require TARGET_PATH."/{$target}.php";
        $pageView = ob_get_clean();
    }
    require TARGET_PATH."/frame/layout.php";
} else {
    require TARGET_PATH."/error.php";
}

My routes' file routes.php looks like:

<?php

$router->map('GET', '/', 'home', 'home');
$router->map('GET', '/contact', 'contact', 'contact');
$router->map('GET', '/about', 'about', 'about');
$router->map('GET', '/achievements', 'achievements', 'achievements');
$router->map('GET', '/achievements/[*:slug]', 'achievements', 'achievement');
$router->map('GET', '/projects', 'projects', 'projects');
$router->map('GET', '/projects/[*:slug]', 'projects', 'project');
$router->map('GET', '/news', 'news', 'news');
$router->map('GET', '/news/[*:slug]', 'news', 'single_news');

?>

And my .htaccess

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

The thing is I can get routes when I run le PHP sel-server but can't my css and javascipt files (I say Ok, I can fix it later) Now I'm trying to see how it works on my localhost but all I can reach is the error page error.php

What am I missing?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda