skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    The right solution was changing my htaccess to:

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

  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search