使用 htaccess 规则将 API 路径重定向到 Slim Routes
Redirect API path using htaccess rule to Slim Routes
我有一个 API 这样的路径
http://localhost/myProject/public/delivery/324
因此,每当我使用 {projectPath}/delivery 或 {projectPath}/delivery/{id} 访问 API 时,API ping public/delivery/index。php 当我在 htaccess 中编写 RewriteRule 时
RewriteRule ^delivery/(.*)$ delivery/index.php [QSA,NC,L]
而我的 delivery/index.php 包含如下所示的实际纤细路线,
<?php
$app = new \Slim\App(["settings" => $config]);
$app->group("/delivery", function(){
$this->post("", "MyController:createDelivery");
$this->get("/{id}", "MyController:getDeliveryId");
});
$app->run();
即将控制 delivery/index。php。但是,slim routes 不工作并且它没有 ping MyController
。我在这里遗漏了什么吗?
根据 Pipe 的评论,我的工作如下,
$app->post("/", "MyController:createDelivery");
$app->get("/{id}", "MyController:getDeliveryId");
我有一个 API 这样的路径
http://localhost/myProject/public/delivery/324
因此,每当我使用 {projectPath}/delivery 或 {projectPath}/delivery/{id} 访问 API 时,API ping public/delivery/index。php 当我在 htaccess 中编写 RewriteRule 时
RewriteRule ^delivery/(.*)$ delivery/index.php [QSA,NC,L]
而我的 delivery/index.php 包含如下所示的实际纤细路线,
<?php
$app = new \Slim\App(["settings" => $config]);
$app->group("/delivery", function(){
$this->post("", "MyController:createDelivery");
$this->get("/{id}", "MyController:getDeliveryId");
});
$app->run();
即将控制 delivery/index。php。但是,slim routes 不工作并且它没有 ping MyController
。我在这里遗漏了什么吗?
根据 Pipe 的评论,我的工作如下,
$app->post("/", "MyController:createDelivery");
$app->get("/{id}", "MyController:getDeliveryId");