首页 > 解决方案 > Laravel 使用 Redirect::to() 重定向到其他文件存储

问题描述

$url = 'file:\\company8\Production\2018\2018-12\Product1';
return Redirect::to($url);

// 这会重定向到http://127.0.0.1:8000/file:/company8 \Production\2018\2018-12\Product1

// 如何让 laravel 重定向到文件:/company8\Production\2018\2018-12\Product1

标签: laravelredirect

解决方案


尝试将反斜杠()更改为斜杠(/)。

但是,由于安全原因,您无法重定向到文件协议。

当您重定向到它时

return Redirect::to("file://company8/Production/2018/2018-12/Product1");

ERR_UNSAFE_REDIRECT将从 chrome 收到。

尝试通过回应

return response()->file('/company8/Production/2018/2018-12/Product1');

推荐阅读