4
我想重定向到一个页面(例如error.php),具体取决于我网站中表单中的信息。我设法登录这样的错误:重定向到Slim框架出错的另一个页面
if ($date > $curdate) {
return $response
->withStatus(406)
->withHeader('Content-Type', 'text/html')
->write('You can\'t select dates in the future!');
}
我怎么能做到这一点,因此特别,而不是记录/发送你到一个页面的错误,要求其在网络选项卡?
现在我得到这样的:
Request URL:http://raspberrypi/chartAPI/api/{id}/{date1}/{date2}
Request Method:POST
Status Code:406 Not Acceptable
Remote Address:192.168.0.80:80
Referrer Policy:no-referrer-when-downgrade
如预期这几乎是工作。我想要做的是将它发送给“http://raspberrypi/chartAPI/error/406”(例如),并将内容显示在一个名为406.php(或error406.php,或error.php或任何调用它)的文件中。
我设法做一些与此:
return $response->withRedirect("error.php");
但我得到这个:
Request URL:http://raspberrypi/chartAPI/api/{id}/{date1}/error.php
Request Method:GET
Status Code:405 Method Not Allowed
苗条抛出这个错误:
Method not allowed. Must be one of: POST
为什么删除{DATE2 }?为什么它要求POST方法?
这个问题的this one延续,但由于该网站如何处理这些“老”问题,幸亏有推下来,不管我有多少编辑说,它没有得到任何注意了。
可能重复[重定向在Slim框架上出现错误](http://stackoverflow.com/questions/43611649/redirecting-with-error-on-slim-framework) – geggleto
@geggleto这就是我在最后说的这个问题。 – Newwt