【发布时间】:2012-09-01 16:18:59
【问题描述】:
我被困在这里,在 wamp 中我运行一切并且工作正常,但是,当我尝试在 centos 盒子中安装我的 api 时,我总是收到“未找到”错误。
我不知道还能做什么!
即使是 say/hello 示例也失败了...
是否有任何关于处理 restler 的 apache 要求规范?
有什么想法吗?有点急
say.php:
<?php
class Say {
function hello($to='world') {
return "Hello $to!";
}
}
index.php
<?php
require_once 'restler/restler.php';
require_once 'say.php';
$r = new Restler();
$r->addAPIClass('Say');
$r->setSupportedFormats('jsonpformat', 'jsonformat', 'xmlformat', 'yamlformat');
$r->handle();
.htaccess
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
<IfModule mod_php5.c>
php_flag display_errors On
</IfModule>
错误:
未找到 在此服务器上找不到请求的 URL /mylocation/say/hello。
这基本上是我所有的代码,如果你们认为 jsonpformat 可能会妨碍我,我可以将代码粘贴在这里。
当我像这样输入网址时:http://myhost/mylocation/ 我收到一个 json 错误:
{
"error": {
"code": 404,
"message": "Not Found"
}
}
如果我输入 http://myhost/mylocation/say/hello 然后我得到 not found 错误,就像 .htaccess 不起作用。
[编辑]
如果我像这样将“index.php”添加到 url 中似乎可以工作:http://myhost/mylocation/index.php/say/hello,但我不能像这样离开它......
我来自:Restler returns 404 status code if index.php is not included in URL
【问题讨论】:
-
如果很紧急,您应该告诉我们更多细节
-
我已经完成了对问题的改进,但是,我真的可以使用一些关于 apache 和 php 的 restler 要求的信息,以防我在安装中错过了一些模块或扩展。
-
您的
.htaccess文件似乎没问题,所以您的mod_rewrite- check if it's installed 可能有问题。 -
事实上@moonwave99 我不得不将 httpd.conf 文件的 de AllowOverride 变量设置为 All 而不是 None
标签: php web-services api rest restler