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

Ap3twe's avatar

Storage link returning 404 on production

The storage folder is pointing to the public folder correctly. The path is storage -> ../storage/app/public

0 likes
14 replies
Ap3twe's avatar

This is how I am calling it the mail view. The first returns 404 and the second 403 forbidden

@component('mail::button', ['url' => 'https://pabok.com/uploads/removableprosthetics/'. $removableProsthetics->pdf_file])
Download Case PDF
@endcomponent
@component('mail::button', ['url' => 'https://pabok.com/storage/uploads/removableprosthetics/'. $removableProsthetics->pdf_file])
Download Case PDF
@endcomponent

I print ls public -la I get :

drwxr-xr-x  8 pabok psacln      4096 Feb 16 16:48 .
drwxr-x--- 14 pabok psaserv     4096 Feb 16 16:33 ..
drwxr-xr-x  2 pabok psacln      4096 Sep 22 19:36 1
-rw-r--r--  1 pabok psacln  11561151 Sep 28 19:45 1.part
drwxr-xr-x  5 pabok psacln      4096 Jan 28 14:01 css
-rwxr-xr-x  1 pabok psacln     12292 Feb 12 20:14 .DS_Store
-rwxr-xr-x  1 pabok psacln         0 Sep 22 19:36 favicon.ico
-rwxr-xr-x  1 pabok psacln       593 Sep 22 19:36 .htaccess
drwxr-xr-x 11 pabok psacln      4096 Feb 12 20:14 images
-rwxr-xr-x  1 pabok psacln      1823 Sep 22 19:36 index.php
drwxr-xr-x  5 pabok psacln      4096 Nov 25 16:33 js
drwxr-xr-x  2 pabok psacln      4096 Sep 22 19:36 logo
-rwxr-xr-x  1 pabok psacln        71 Sep 22 19:36 mix-manifest.json
-rwxr-xr-x  1 pabok psacln        24 Sep 22 19:36 robots.txt
lrwxrwxrwx  1 root     root          21 Feb 16 16:48 storage -> ../storage/app/public
drwxr-xr-x  5 pabok psacln      4096 Sep 22 19:36 vendor

I have tried storage:link , ln -s ../storage/app/public storage. Both create the storage link but the files in the browser returns 404.

https://pabok.com/uploads/nineline/webdevprotec/Daniel-splints-2021-02-1613:54:12.pdf . It returns 404 on production but works local machine

Maria30's avatar

@ap3twe remove the storage link and generate it again from the terminal of your production environment

Ap3twe's avatar

I have tried it, same problem

sr57's avatar

It's a pb of rights or path.

3 things to check

  • owner & group : why not www-data?

  • link : why not absolute?

  • url - path/file exists?

Ap3twe's avatar

The absolute path is /var/www/vhosts/***.com/httpdocs/public/storage The path exists it saves all files to the correct path.

zoidq's avatar

Based on the .htaccess file I assume you're using Apache?

Is everything setup to follow symlinks?

Options +FollowSymLinks
Ap3twe's avatar

Apache nginx, do I have to edit the htaccess?

zoidq's avatar

Yes, add that line above to the .htaccess file.

You can find out more using from their docs if that doesn't work perfectly the first time.

sr57's avatar

The absolute path is /var/www/vhosts/***.com/httpdocs/public/storage The path exists it saves all files to the correct path.

You don't understood my questions

-2- storage -> ../storage/app/public

It's a relative link, when you do the command : php artisan storage:link , it creates an absolute path

-3- dump your url to be sure it contains what you want

dd('https://pabok.com/storage/uploads/removableprosthetics/'. $removableProsthetics->pdf_file)

Could be also useful to reread https://laravel.com/docs/8.x/filesystem#file-uploads

Ap3twe's avatar
Ap3twe
OP
Best Answer
Level 5

Thank Yall.@sr57 @zoidq It was really a Plesk server. The cause "Symbolic links are not allowed in Apache configuration" I checked the server logs and found AH00037: Symbolic link not allowed or link target not accessible: /var/www/vhosts/***.com/httpdocs/public/storage With your direction I added your suggestion

Options +FollowSymlinks to htaccess, but that did not work then I found there is another Options -SymLinksIfOwnerMatch which disable symbolic link owner check.

That resolved the problem. hope this is the right solution. Thanks

sr57's avatar

Hi @ap3twe

That resolved the problem.

Yes, ... you can always change standard config and make a system not working.

You never answered to my 1rst question ; owner & group : why not www-data?

hope this is the right solution

No pb of functionality and security but you degrade performance.

FollowSymLinks and SymLinksIfOwnerMatch

Wherever in your URL-space you do not have an Options FollowSymLinks, or you do have an Options SymLinksIfOwnerMatch, Apache will need to issue extra system calls to check up on symlinks. (One extra call per filename component.)

PS : no need to add +FollowSymlinks, it's the default option.

https://httpd.apache.org/docs/2.4/fr/mod/core.html

Ap3twe's avatar

Your first question I have tried www, HTTP, HTTPS, all gave me the same error. I found the error in the server log AH00037: Symbolic link not allowed or link target not accessible: /var/www/vhosts/***.com/httpdocs/public/storage Googling it is a common issue for PHP frameworks deploying to Plesk servers.

Please or to participate in this conversation.