Home > Enterprise >  Laravel root directory not public on Hostinger hosting
Laravel root directory not public on Hostinger hosting

Time:12-14

I currently host my Laravel website on Hostinger, but when I have a image on my page, the url doesn't go to website.com/public/img_url, but it goes to website.com/img_url, does anyone know how this works on Hostinger, and how I can fix this?

Currently my whole project is in my public_html, with no other folders besides it.

CodePudding user response:

You should need to add a public inside asset function to access a public folder on the shared hosting server.

So you need to change the fetch path of files Example: asset('user/photo.jpg') to asset('public/user/photo.jpg') in each line of code where you need to fetch files from the public directory.

CodePudding user response:

The right solution was changing my htaccess to:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
  • Related