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

Documentation for setting base path incorrect. #171

Open
elliotboney opened this issue Nov 17, 2016 · 4 comments
Open

Documentation for setting base path incorrect. #171

elliotboney opened this issue Nov 17, 2016 · 4 comments

Comments

@elliotboney
Copy link

Just a quick edit to the set base path documentation to save some other people the confusion.

It's documented as

$router->setBasePath('/alto-app/');

and what works is only (without the /):

$router->setBasePath('alto-app');
@NoMan2000
Copy link

A bit more details to help out anyone else, and I'll probably submit a pull request later.

The general matcher uses $_SERVER['REQUEST_URI'] which will return a path like:

/foo/bar/?param=value&param2=value2

If you set this value $router->setBasePath('/alto-app/');, you end up with this result.

 /alto-app//foo/bar/?param=value&param2=value2

Note those two forward slashes in the route, which won't match anything.

If you do @elliotboney's route, you get this:

alto-app/foo/bar/?param=value&param2=value2

May or may not be what you want. I set it with $router->setBasePath('/alto-app');

/alto-app/foo/bar/?param=value&param2=value2

@koenpunt
Copy link
Collaborator

I believe setBasePath('/my-base') is the correct way. We could just strip the right / from the path when setting it.

@milankragujevic
Copy link

Can confirm, rtrim($base, '/') fixed all my issues.

@dejurin
Copy link

dejurin commented Sep 9, 2018

I think with / and without it's same, but work another. How about fix it?

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

5 participants