If I set the base path with a slash at the end, this will cause the match() function always returning false.
For example the base path $router->setBasePath('/some-base-path/') causes match() method to return false always. The root cause for this is in the value returned by substr() function in AltoRouter/AltoRouter.php line 179:
// strip base path from request url
$requestUrl = substr($requestUrl, strlen($this->basePath));
Here substr() returns false instead of / for a root url index. Although for other urls It will remove the slash at the beginning of the request url. So in this situation the match will always return false.
However If I remove the slash from the end of base path, it works.
Hi there,
This is my scenario. The following is the directory structure for my project, which is accessible via
http://localhost/phpprac
:And this is the
index.php
:And this is the output:
boolean false
If I set the base path with a slash at the end, this will cause the
match()
function always returningfalse
. For example the base path$router->setBasePath('/some-base-path/')
causesmatch()
method to returnfalse
always. The root cause for this is in the value returned bysubstr()
function inAltoRouter/AltoRouter.php
line 179:Here
substr()
returnsfalse
instead of/
for a root url index. Although for other urls It will remove the slash at the beginning of the request url. So in this situation the match will always return false.However If I remove the slash from the end of base path, it works.
$router->setBasePath('/some-base-path')