【发布时间】:2015-07-08 19:44:48
【问题描述】:
我正在尝试使用 php 和 php slim 创建一个 API。
我的文件夹结构:
API:
- app -> app.js
- 库 -> 苗条
- v1 -> .htaccess 和 index.php
htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]
index.php
require '.././libs/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app = \Slim\Slim::getInstance();
$app->get('/orderoverview/:customerID', function ($customerID) {
echo "Hello " . $customerID;
});
$app->run();
这应该很容易,但每次我去http://localhost/api/v1/orderoverview/2 我都会得到一个 404 Page Not Found。
但是当我转到http://localhost/api/v1/index.php/orderoverview/2 时,我确实得到了我想要的结果!
有什么意见或解决办法吗?
【问题讨论】: