1
I’m trying to follow the slim tutorial here, but always give page not found when localhost:8080/hello/Alan access.
I’m using iis 10. I installed rewrite url 2.0, and my web.config looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="slim" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The directory structure of my application is:
.
project
src
public
The root of the site is the public folder and in it are the index.php and web.config files.
The code of index.php is:
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require '../vendor/autoload.php';
$app = new \Slim\App;
$app->get('hello/{name}', function(Request $request, Response $response, array $args){
$name = $args['name'];
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();
I looked for help on the Internet and got no answer.