所有路线上的Restler 3:404

时间:2015-06-05 16:38:00

标签: php restler

我正在尝试在PHP app api中使用Restler,但我在所有请求中都返回了404个对象。我已经回顾了以下类似的问题:

我几乎可以肯定问题在于服务器配置。我可以在本地环境中运行示例文件,但只要将其推送到实时服务器,此问题就会持续存在。

例如,当我复制_001_helloworld本地工作的文件夹to my server时,我得到404响应正文:

{
error: {
code: 404,
message: "Not Found"
},
debug: {
source: "Routes.php:431 at route stage",
stages: {
success: [
"get"
],
failure: [
"route",
"negotiate",
"message"
]
}
}
}

Here is my PHPInfo

如何修复Restler中响应正文中返回404的所有路由。

1 个答案:

答案 0 :(得分:1)

Ik spent an entire day solving this exact same problem but finally managed to do so. On localhost everything was running smoothly but on the server I got the same 404 error ("Routes.php:431 at route stage") as you did. This is what solved it for me: I had to move the .htaccess to the root of the website and then changed the RewriteRule to have [location of your api]/index.php instead of just index.php. My .htaccess file: Options -MultiViews DirectoryIndex api/helloworld/index.php <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^$ api/helloworld/index.php [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ api/helloworld/index.php [QSA,L] </IfModule> <IfModule mod_php5.c> php_flag display_errors Off </IfModule> Basic hello world example can now be called like this: GET [servername]/say/hello