簡體   English   中英

使用htaccess規則將API路徑重定向到Slim Routes

[英]Redirect API path using htaccess rule to Slim Routes

我有這樣的API路徑

HTTP://本地主機/ myProject的/公/交付/ 324

因此,每當我使用{projectPath} / delivery或{projectPath} / delivery / {id}來訪問API時,API都會在我在htaccess中編寫RewriteRule時對ping / public / delivery / index.php進行ping操作,例如

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。 但是,纖細的路由不起作用,並且無法ping MyController 我在這里想念什么嗎?

根據Pipe的評論,我的工作如下

$app->post("/", "MyController:createDelivery");
$app->get("/{id}", "MyController:getDeliveryId");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM