[英]Restler always returns not found
I'm stuck here, in wamp I run everything and works fine, however, when I tried to install my api in a centos box, I always get a "Not Found" error. 我被困在这里,在沼泽中,我可以正常运行一切,但是,当我尝试将我的api安装在centos盒中时,总是出现“未找到”错误。
I dont know what else to do! 我不知道该怎么办!
Even the say/hello example fails... 甚至say / hello示例也失败了...
Is there any specification of the apache requirements to handle restler? 是否有关于处理Restler的apache要求的规范?
Any ideas?, it is kind of urgent 有什么想法吗,这很紧急
say.php: say.php:
<?php
class Say {
function hello($to='world') {
return "Hello $to!";
}
}
index.php 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 .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>
error: 错误:
Not Found The requested URL /mylocation/say/hello was not found on this server. 找不到在此服务器上找不到请求的URL / mylocation / say / hello。
Thats basically all my code, if you guys think that jsonpformat might be steping in my way I could paste that code here. 基本上就是我的所有代码,如果你们认为jsonpformat可能会妨碍我,我可以在此处粘贴该代码。
When I type the url like this: http://myhost/mylocation/
I get a json error: 当我这样输入网址时:
http://myhost/mylocation/
我收到json错误:
{
"error": {
"code": 404,
"message": "Not Found"
}
}
If I type http://myhost/mylocation/say/hello
then I get the not found error, its like .htaccess isn't working. 如果输入
http://myhost/mylocation/say/hello
则会收到未找到的错误,例如.htaccess无法正常工作。
[EDIT] [编辑]
It seems to work if I add "index.php" to the url like this: http://myhost/mylocation/index.php/say/hello
, but I can't leave it like this... 如果我将“ index.php”添加到网址中似乎是
http://myhost/mylocation/index.php/say/hello
,例如: http://myhost/mylocation/index.php/say/hello
,但我不能这样保留它...
I got this from: Restler returns 404 status code if index.php is not included in URL 我是从这里得到的: 如果URL中未包含index.php,Restler返回404状态代码
Ok, I found the problem, thanks everyone for your help. 好的,我发现了问题,谢谢大家的帮助。
The solution was to set the AllowOverride
variable of the httpd.conf
file to All
instead of None
. 解决方案是将
httpd.conf
文件的AllowOverride
变量设置为All
而不是None
。 As soon as I tried that it worked :) 一旦我尝试它起作用:)
Besides the mod_rewrite of apache, I didn't find another requirement to run restler, if I do, I'll edit this and put it here. 除了apache的mod_rewrite之外,我没有发现运行restler的其他要求,如果可以,我将对其进行编辑并将其放在此处。
I found that this is a common issue with restler and it might be good to mention it in the documentation, hope this can help you. 我发现这是restler的常见问题,在文档中提及它可能会很好,希望对您有所帮助。
PD : I must say that is very annoying to be voted down while editing my question when it didn't even passed a minute since I posted it, however I did as fast as I could. PD :我必须说,自从我发布问题以来还没有过一分钟,当编辑我的问题时被投票否决是非常令人讨厌的,但是我尽了全力。 You might say "why did yout posted it then?"
您可能会说“那为什么不张贴呢?” Because of the restler requirements part, it doesn't require much detail to answer that...
由于存在Restler需求部分,因此不需要太多细节即可回答...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.