I’m considering using Slim 3 for our upcoming API. We are currently using Lighttpd for the web interface, however, I have been unable to get the rewrite rule to work. The following is my config in lighttpd.conf:
$SERVER["socket"] == "0.0.0.0:6549" {
ssl.engine = "enable"
ssl.cipher-list = "aRSA+HIGH !3DES +kEDH +kRSA !kSRP !kPSK"
ssl.pemfile = "/mnt/kd/ssl/webinterface.pem"
ssl.ca-file = "/mnt/kd/ssl/https_ca_chain.pem"
server.document-root = "/var/www/api/public"
accesslog.filename = "/var/log/lighttpd/ssl-access.log"
url.rewrite-if-not-file = ("^(.*)" => "/index.php/$0")
url.access-deny = ( "~", ".inc", ".htpasswd", ".htaccess" )
dir-listing.activate = "disable"
}
Accessing https://serverurl.com:6549/ or https://serverurl.com:6549/index.php works, though when I try https://serverurl.com:6549/hi it comes up with a 404 not found. The following is my index.php:
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require '/mnt/kd/phpmgr/vendor/autoload.php';
$app = new \Slim\App;
$app->get('/', function (Request $request, Response $response, array $args) {
$response->getBody()->write("Hi");
});
$app->get('/hi', function (Request $request, Response $response, array $args) {
$response->getBody()->write("Hi");
});
$app->run();
});