php - Laravel 在斜杠上重定向 [ / ]
问题描述
Laravel 正在从OPTIONS方法重定向到GET方法。
web.php(路由)
Route::any('/files/{document?}','webDavController@dispatch')->name('webDav');
webDavController.php
private $allowMethods = array('options','get','head','post','delete','trace','propfind','proppatch','copy','mkcol','put');
public function dispatch( $fileId = false ){
$method = strtolower($_SERVER['REQUEST_METHOD']);
if(in_array($method, $this->allowMethods)){
switch ($method){
case "get":
$this->getFile();
break;
case "put":
$this->putFile();
break;
case "options":
$this->getOptions();
break;
}
}
}
阿帕奇访问日志
x.x.x.x - - [07/Jan/2020:10:49:37 -0500] "OPTIONS /files/ HTTP/1.1" 301 246 "-" "PostmanRuntime/7.21.0"
x.x.x.x - - [07/Jan/2020:10:49:37 -0500] "GET /files HTTP/1.1" 200 68280 "https://server.com/files/" "PostmanRuntime/7.21.0"
为什么会发生这种重定向?我该如何解决它,为什么要重写为GET?我按照其他用户的建议做了一个 apache mod-rewrite,但仍然存在问题,也许我做得不对。
解决方案
推荐阅读
- python - 如何比较具有不同索引的两个数据帧,并打印出重复的行?
- python - 如何在循环中创建按钮列表时将不同的参数传递给函数
- angularjs - App Engine 中的服务有时会返回 431
- python - cx_Freeze 没有名为 locket 的文件
- android-jetpack-compose - 如何在 Jetpack Compose 列中指定子项之间的确切间距?
- node.js - VSCode 调试器 - 启动时未找到“节点”错误
- java - 限制每次来自 Log4j2 SMTPAppender 的电子邮件数量
- c# - 为什么循环遍历 Excel 单元格并比较值需要这么长时间?
- c++ - 检测重复词
- java - 运行 Debian Buster LXDE 的 BeagleBone Black Industrial 上的空白 Java 窗口?