-
Notifications
You must be signed in to change notification settings - Fork 442
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
Less information #71
Comments
The .htaccess for this kind of thing is pretty standard. This should do the trick:
That said, I don't understand what you mean by subfolder. The routes are relative to your |
Set RewriteBase to the subfolder
|
@olvlvl : $dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) {
$r->addRoute('GET', '/users', 'get_all_users_handler');
// {id} must be a number (\d+)
$r->addRoute('GET', '/user/{id:\d+}', 'get_user_handler');
// The /{title} suffix is optional
$r->addRoute('GET', '/articles/{id:\d+}[/{title}]', 'get_article_handler');
}); This code not working because system router expect localhost/users/name/id and we have localhost/project/cms/users/name/id |
If |
My $_SERVER['DOCUMENT_ROOT'] = C:/xampp/htdocs this is default settings server after installation completed. |
@MESWEB Do you need to give the dispatcher the path info? e.g.: $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo()); |
This issue is still open, if it has been resolved please close it. $dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) {
$base_url = '/project/cms';
$r->addRoute('GET', $base_url.'/users', 'get_all_users_handler');
// {id} must be a number (\d+)
$r->addRoute('GET', $base_url.'/user/{id:\d+}', 'get_user_handler');
// The /{title} suffix is optional
$r->addRoute('GET', $base_url.'/articles/{id:\d+}[/{title}]', 'get_article_handler');
}); Then moving from your local machine to production server, can be as simple as changing |
@snopboy Yes I'm using this but this is very bad idea for using better if author make automatic structure of folders. |
@MESWEB Why aren't you using path info as @samwilson suggested? All the necessary information should be in the |
@Trainmaster I'm using this solution but when somebody have different structure. This fix should be a automatic recognize folder structure. |
You also can remove a certain prefix from the URL to be matched against (i.e. leave routes as is, just alter input route). This should be the cleanest way to solve that issue. Fixing this is not really a concern of FastRoute - it's just matching routes based on input. E.g. |
Can we close this issue now? |
Closing this issue in favor of #110, which talks about the prefix issue more specifically. My conclusion there is: We might add a helper for uri preprocessing to handle the query string / decoding / prefix removal, but this library will not implement any automagic for guessing which URI to match against, as the logic for this across different servers and sapis is involved and there are other libraries dealing with the intricacies already. |
This script has less information about using it. Where is info about .htaccess? Why in basic usage is:
"$r->addRoute('GET', '/user/{id:\d+}/{name}', 'handler2');" this is not working when anyone using subfolder as root of script. because router don't expecting subfolder/user/12/mario.
The text was updated successfully, but these errors were encountered: