You cannot call plan.php by passing plan.php as an argument to the match function
Check out the examples at http://altorouter.com/usage/processing-requests.html
If you want to use content from plan.php
you must use map in the following format
$router->map('GET','/plan/', function() { require __DIR__ . '/plan/plan.php'; } , 'plan');
add echo 'testing plan'; plan/plan.php file echo 'testing plan';
Also, check that your .htaccess file contains
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L]
Also, if you set the base path using $router->setBasePath('/alto'); , your index.php files must be placed in the alto directory so that your URL is in this case http://example.com/alto/index.php
Working example:
require 'lib/AltoRouter.php'; $router = new AltoRouter(); $router->setBasePath('/alto'); $router->map('GET','/plan/', function( ) { require __DIR__ . '/plan/plan.php'; } , 'plan'); // match current request $match = $router->match(); if( $match && is_callable( $match['target'] ) ) { call_user_func_array( $match['target'], $match['params'] ); } else { // no route was matched header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found'); }
then it will work great
<a href="<?php echo $router->generate('plan'); ?>">Plan <?php echo $router->generate('plan'); ?></a>
Pawel dubiel
source share