I'm learning Slim Framework and got stuck with its routing.
Working Code. Code snippet #1:
$app = new \Slim\App();
$app->get("/", function () {
echo "Hello SlimFramework";
});
$app->run();
Not Working. Code snippet #2:
$app = new \Slim\App();
$app->get("/hello/{name}", function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();
I'm getting "Not Found The requested URL /hello/name was not found on this server." for Code snippet #2. Any clue what's going on here ?
.htaccess File
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
Thanks in advance !
I had to start with clean slate in order to solve this issue for me. @ceejayoz's solution about making sure if .htaccess is working correctly, was a great help to test .htaccess configuration.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.