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

maheshshittlani's avatar

Shared server hosting problem

i have deploy my site on shared server and everything working fine. only the images stored in storage folder are not displaying.

I have tried creating storage link but not working.

My server is centos and using apache.

0 likes
2 replies
lostdreamer_nl's avatar

It could be that your shared server is setup to 'not follow symlinks'.

First try if you can change that in public/.htaccess Add this to the top of the file:

Options +FollowSymLinks

If that still doesnt work, then they probably turned it off on server level.

In that case you can use a route to do it for you (but it will load image files in PHP which will be slower then using a static route).

But if it's all you have: routes.php:

Route::get('images/{image}', function($image) {
    $storagePath = 'app/public/';
    if(file_exists(storage_path($storagePath . $image)) {

        $file_extension = strtolower(substr(strrchr($image,"."),1));
        switch( $file_extension ) {
            case "gif": $ctype="image/gif"; break;
            case "png": $ctype="image/png"; break;
            case "jpeg":
            case "jpg": $ctype="image/jpeg"; break;
            default:
        }

        header('Content-type: ' . $ctype);
        echo file_get_contents( storage_path($storagePath . $image) );
        exit;
    }
});

It will load images on the URI: domain.com/images/image-name.jpg and will try to fetch them from: storage/app/public/image-name.jpg

Change the line with $storagePath = '....' to get the images from another subfolder.

jlrdw's avatar

And if that does not work try putting

ob_clean();

just before

echo file_get_contents( storage_path($storagePath . $image) );

Please or to participate in this conversation.