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 :
But when I'm trying to view the image by clicking the image link, it always redirected to /public directory
Result Image
CodePudding user response:
You can create .htaccess in your root and add these lines and check.
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]
CodePudding user response:
First, you make a .htaccess file and write this code
RewriteEngine On RewriteCond %{REQUEST_URI} !^/public/ RewriteRule ^(.*)$ /public/$1 [L,QSA]