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

Benounnas Oussama's avatar

Storage link not working on shared host

Hello, i had a client who already bought a shared hosting which i was obliged to deploy there an api of a website, i searched for solutions to run artisan commands inside the shared server. I faced a problem where i had to recreate a symbolic link for the storage, since i don't have ssh access, i used to run the artisan commands:

Route::get('/', function () {
  Artisan::call("cache:clear");
  Artisan::call("config:clear");
  Artisan::call("optimize:clear");
  Artisan::call("storage:link");
    
});

it created the sys link (screenshot) but when i visite mydomain.com/storage/image.png it throws a 404 not found error, contrary when i try mydomain.com/storage/app/public/image.png, it works normally, even when i double click on that sys link it takes me to the storage/app/public folder (like it should to be). I don't know if i gave the whole description for the problem, any idea how to fix it? thnx

0 likes
5 replies
Snapey's avatar

Just shows that you have not installed your site correctly. You are serving the root of the project and not the public folder.

This is a big security risk as well as having all your URLs polluted with /public/

Benounnas Oussama's avatar

i didn't understand exactly, can you elaborate more, an example would be appreciated if you can

Snapey's avatar
Snapey
Best Answer
Level 122

your public folder should be the one treated by the webserver as document root

it's difficult to give examples without knowing what type of hosting it is

1 like
Benounnas Oussama's avatar

indeed i figure it out why the sys link didn't work, you're right!, i used to move the index.php file which was treated as the document root, i did move it again to the public folder where it belongs, repointed the websever again to the public folder (since it's was a subdomain), it worked like a charm

DeteCT0R's avatar

Most of the shared hosting disable some commands for security reason.

Artisan::call("storage:link");

Its just a shortcut for symlink command.

1 like

Please or to participate in this conversation.