我正在使用自定义文件存储磁盘,该磁盘在本地计算机上可以正常工作,但是在Forge服务器上,生成的资产URL无法正常工作。
我的文件系统配置如下:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'assets' => [
'driver' => 'local',
'root' => storage_path('app/public/assets'),
'url' => env('APP_URL').'/assets',
'visibility' => 'public',
],
];
我在{myapp root}/storage/app/public/assets/file.jpg
有一个文件,并且正在使用Storage::disk('assets')->url('file.jpg');
生成URL,这可以正常工作,它为我提供了预期的URL,(本地)myapp.test/assets/file.jpg
。在生产中,我也获得了正确的URL myapp.com/assets/file.jpg
,但是此链接404s。如果我在网址中插入“存储”,以使其为myapp.com/storage/assets/file.jpg
,那么它将起作用。
我已经php artisan storage:link
在这两种环境中进行了所有操作,所有其他操作都完全相同,但是在真实服务器上,所有URL均为404。
帮助!