简体   繁体   English

Restler 3:所有路线上的404

[英]Restler 3: 404 on all routes

I am trying to use Restler in a PHP app api, but I am getting a 404 object returned on all requests. 我正在尝试在PHP应用程序api中使用Restler,但在所有请求中都返回了404对象。 I have reviewed the following similar questions: 我已经审查了以下类似问题:

I am almost certain that the problem lies in the server configuration. 我几乎可以确定问题出在服务器配置上。 I can run the example files in my local environment, but as soon as I push it to the live server, this problem persists. 我可以在本地环境中运行示例文件,但是将其推送到实时服务器后,此问题仍然存在。

For example, when I copy the folder _001_helloworld , which works locally, to my server , I get 404 response body: 例如,当我将本地_001_helloworld的文件夹_001_helloworld复制到服务器上时 ,得到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 这是我的PHPInfo

How can I fix all routes returning 404 in the response body in Restler. 如何在Restler的响应正文中修复所有返回404的路由。

Ik spent an entire day solving this exact same problem but finally managed to do so. Ik花了一整天的时间解决了这个完全相同的问题,但最终设法做到了。 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. 在localhost上,一切都运行顺利,但是在服务器上,您却遇到了相同的404错误(“ Routes.php:431 at route stage”)。

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. 我必须将.htaccess移至网站的根目录,然后将RewriteRule更改为具有[api的位置] /index.php,而不只是index.php。

My .htaccess file: 我的.htaccess文件:

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 现在可以像这样调用基本的hello world示例:GET [服务器名] / say / hello

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM