Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass parameter just after domain #220

Open
pcexpert247 opened this issue Apr 27, 2018 · 1 comment
Open

Pass parameter just after domain #220

pcexpert247 opened this issue Apr 27, 2018 · 1 comment

Comments

@pcexpert247
Copy link

pcexpert247 commented Apr 27, 2018

Hi All,
I am using altorouter for routing the paths but I want to use the parameters just after the domain like http://example.com/category-name which when executed gives the category name to the PHP file which then loads the data according to category name. My index file is like this:

` require 'lib/AltoRouter.php';

$router = new AltoRouter();
$router->setBasePath('example.com/');

$router->map( 'GET', '', function() {
	 require __DIR__ . '/home.php';
});	

$router->map( 'GET', '/', function() {
	 require __DIR__ . '/home.php';
});	

$router->map( 'GET', '/home', function() {
		require __DIR__ . '/home.php';
});

$router->map( 'GET', '/directory', function() {
		require __DIR__ . '/directory.php';
});
$router->map( 'GET', '/[*:name]', function() {
		require __DIR__ . '/category.php';
});

$match = $router->match();

if($match && is_callable( $match['target'] )) {
		call_user_func($match['target'], $match['params']);
	} 
else {
		echo "not working";
};

`

I have found one issue similar to this https://stackoverflow.com/questions/36351681/altorouter-cant-figure-out-how-to-route-correctly-php

I want results like this described in this issue.
Can anyone help me out in this issue?

@koenpunt
Copy link
Collaborator

You probably should not include the domain name in the base path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants