【发布时间】:2012-12-28 11:39:41
【问题描述】:
我正在尝试使用 Slim 框架在 Appfog 中设置一个 REST 应用程序。这是基于 Coenrats 在此链接中的教程: http://coenraets.org/blog/2011/12/restful-services-with-jquery-php-and-the-slim-framework/
只有我使用了更新版本的框架。文件夹结构如下
应用程序
--> api
----> .htaccess
----> index.php
----> Slim 框架文件夹
--> js
----> jquery.js
----> main.js
--> CSS
----> 样式.css
--> index.html
这是我如何瘦身的代码
// load required files
require 'Slim/Slim.php';
// register Slim auto-loader
\Slim\Slim::registerAutoloader();
// initialize app
$app = new \Slim\Slim();
这是我的 .htaccess 代码:
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
因为我在做 REST,所以我也按照教程设置了一个 rootURL:
var rootURL = "http://test.ap01.aws.af.cm/app/api/";
当我运行应用程序时,我正在调用一个 get 方法来获取数据库中的所有数据,但是这个错误显示在我的控制台中:
GET http://test.ap01.aws.af.cm/app/api/ 404(未找到)
我会错过什么吗?
提前致谢。
干杯! 杰森
【问题讨论】:
-
您是否将代码部署到test.ap01.aws.af.cm/app/api?它在本地主机上工作吗?
-
嗨 Odi,是的,它适用于本地主机。我的 localhost 的 rootURl 是localhost/test/api。访问网站时的主 url 不包含 /app/api 的 url,slim 框架和 index.php 只是在 /app/api
标签: php .htaccess rest slim appfog