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

Russelmhardy's avatar

Laravel Project in Hostinger

I now have a problem when I load my Laravel project into "Hostinger" When I browse my domain it works fine But when I browse to my domain /public it gives me the same result

My domain/public page = My domain? How to solve this problem?

0 likes
6 replies
jlrdw's avatar

Same as in development, point to public as document root. Do not follow some of those YouTube videos that tell you to move index around.

3 likes
Russelmhardy's avatar

@jlrdw hi i'm really sorry to to thank u very late Thanks for u reply that true i saw a lot of videos telling move index file , but i don't understand your reply i really clearly can u explain me more please

2 likes
Snapey's avatar

you may also find that your .env file is exposed

2 likes
auriakslt's avatar

@Snapey I am actually just going through this issue. My .env was exposed when testing, so I am trying several configurations now, but seem to be stuck - would be great if somebody could point out the issue, something to try or direction of action. I have tried playing with .htaccess, with no success.

  1. I am using a Hostinger shared hosting called Business Hosting.
  2. Moved project one level up, to the same level as public_html is and symlinked my public with public_html.
  3. Site is loading

ISSUE: built assets are not loading and keep getting 404 for each asset, even if they do exist with correct names and permissions.

jlrdw's avatar

@auriakslt First you don't modify the htaccess that comes with laravel.

You can add another one to root, this one from user @tray2 htaccess

#Rewrite everything to subfolder
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public
Rewriterule ^(.*)$ public/ [L]

I use this one:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^ [N]

RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/ 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php

Make another index.php in root and have only this code:

<?php

require_once __DIR__ . '/public/index.php';

I suggest take the time to learn more about htaccess.

But no matter you achieve this, you need to point to public as document root.

1 like

Please or to participate in this conversation.