Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ahoi's avatar
Level 5

Odd problem: Can not get files on subfolders of a filesystem-disk via HTTP

Hello there,

I got a very odd problem.

On Laravel Forge I can not access files like this:

curl 'https://staging.mydomain.dev/storage/media/11/0ArZWnOzipbdithj.svg'. If I attempt to do that, I am getting the 404-page of the Laravel-App.

This is the filesystems-config:

<?php

return [

    'default' => env('FILESYSTEM_DRIVER', 'local'),

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        'media' => [
            'driver' => 'local',
            'root'   => public_path('media'),
            'url'    => env('APP_URL').'/media',
        ],

        // ...
    ],

    'links' => [
        public_path('storage') => storage_path('app/public'),
    ],

];

The symlink is created correctly:

$ ls -lah public/storage
lrwxrwxrwx 1 stagingmydomaindev stagingmydomaindev 58 Feb 16 13:21 public/storage -> /home/stagingmydomaindev/staging.mydomain.dev/storage/app/public

And the content does exist:

$ ls -lah storage/app/public/media/
total 1.7M
drwxr-xr-x 413 stagingmydomaindev stagingmydomaindev  12K Feb 16 13:09 .
drwxr-xr-x   3 stagingmydomaindev stagingmydomaindev 4.0K Feb 16 13:09 ..
drwx------   3 stagingmydomaindev stagingmydomaindev 4.0K Feb 16 13:09 1
drwx------   3 stagingmydomaindev stagingmydomaindev 4.0K Feb 16 13:09 10
drwx------   3 stagingmydomaindev stagingmydomaindev 4.0K Feb 16 13:09 100
drwx------   3 stagingmydomaindev stagingmydomaindev 4.0K Feb 16 13:09 101
drwx------   3 stagingmydomaindev stagingmydomaindev 4.0K Feb 16 13:09 102
drwx------   3 stagingmydomaindev stagingmydomaindev 4.0K Feb 16 13:09 103
... and many more

Well - if I create a test.txt and move it to ./storage/app/public/media/ and curl it afterwards, I get a result:

curl 'https://staging.mydomain.dev/storage/media/text.txt'
Test

If I move the very same file to a deeper folder like the folder 1 and curl it, I am getting the 404 again.

0 likes
5 replies
Sinnbeck's avatar

Any chance that you have a route that somehow messes with the file system (in web.php)?

ahoi's avatar
Level 5

I thought so, too... But I deleted all those route definitions for testing purposes without any success.

What I see is that it seems to be a problem with the storage-definition. If I use the public disk, the problem is gone.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@ahoi Not sure if it is the cause, but try setting 'visibility' => 'public', on the media storage disk.

1 like
ahoi's avatar
Level 5

@Sinnbeck That was it! Thanks a lot.

So now let me buy you a coffee - you saved my day ;-)

Please or to participate in this conversation.