【问题标题】:Restler 3: 404 on all routesRestler 3:所有路线上的 404
【发布时间】:2015-06-05 16:38:00
【问题描述】:

我正在尝试在 PHP 应用程序 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 的路由。

【问题讨论】:

    标签: php restler


    【解决方案1】:

    Ik 花了一整天的时间来解决这个完全相同的问题,但最终还是成功了。在本地主机上一切运行顺利,但在服务器上我得到了与你一样的 404 错误(“Routes.php:431 at route stage”)。

    这就是为我解决的问题:

    我不得不将 .htaccess 移动到网站的根目录,然后将 RewriteRule 更改为具有 [您的 api 的位置]/index.php 而不仅仅是 index.php。

    我的 .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>
    

    基本的 hello world 示例现在可以这样调用:GET [servername]/say/hello

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-06
      • 1970-01-01
      • 1970-01-01
      • 2011-02-21
      相关资源
      最近更新 更多