Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

279
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda