I asked this same question about a year ago as well, but never realy received an answer, but now I’m facing the exact same problems again. For a multi language site I am using AltoRouter for the Routing. Everything works great except that I have problems with local (js/css) files. When I include css and js files using CDN, everything works just fine, however whenever I use a relative path to local files:
<link rel="stylesheet" href="/css/plugins.min.css">
<script src="/js/plugins.min.js"></script>
Certain rules/classes (css) and functions (js) stop working. I have real no idea how to solve this. For the record, this is what I have in the Router class:
class Router {
private $router;
public function __construct()
{
$config = Config::get('routes');
$this->router = new AltoRouter();
foreach ($config['routes'] as $route => $options) {
$this->router->map( 'GET|POST', $route, $options );
}
}
public function dispatch($route = '/')
{
$match = $this->router->match($route);
if ( $match ) {
$options = array_merge( $match['target'], $match['params'] );
$callable = [new $options['controller']($route), $options['action'] . 'Action'];
$callable($match['params']);
} else {
header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
echo '<pre>', var_dump($this->router, $match), '</pre>';
}
}
}
Does anyone has an idea what I need t adjust to make the local css and js files work as they should?
Thank you in advance