Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Laravel storage link keep redirected to /public directory in hosting

I’m using a hosting service to upload my laravel project and link it to laravel’s public directory using php header location in laravel’s root directory. Then I created a storage link in public directory using symlink or artisan command, but when I’m trying to access the files it always redirected to /public, I wonder why?

Header location index.php

<?php 
    header('Location: public/');
?>

The image link :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Image link under storage directory

But when I’m trying to view the image by clicking the image link, it always redirected to /public directory

Result Image

Result Image

>Solution :

You can create .htaccess in your root and add these lines and check.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading