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

johndoee's avatar

Why laravel app cannot access other pages except welcome page in sharedhosting hostinger

hello i try to host laravel app to hostinger sharedhosting. I place laravel app folder beside public_html folder

folder structure 

--. -- public_html
               |_ index.php
      --  laravelapp
              |_ .htacess

in public_html . has all public folder files because i deleted public folder . i changed index.php as


if (file_exists($maintenance = __DIR__.'/../laravelapp/storage/framework/maintenance.php')) {
    require $maintenance;
}

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/

require __DIR__.'/../laravelapp/vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/

$app = require_once __DIR__.'/../laravelapp/bootstrap/app.php';

$kernel = $app->make(Kernel::class);

$response = $kernel->handle(
    $request = Request::capture()
)->send();

$kernel->terminate($request, $response);

and .htacess file is in root of laravel app


RewriteEngine On
RewriteBase /

RewriteRule ^$ public/index.php [L]

RewriteRule ^((?!public/).*)$ public/ [L,NC]

when i access to domain , it can access welcome page but cannot access login/register page .

Oops, looks like the page is lost.

This is not a fault, just an accident that was not intentional.

something wrong in htacess ?? or folder structures? please help

0 likes
3 replies
Snapey's avatar
Snapey
Best Answer
Level 122

.htaccess should be in the same folder as index.php

1 like
jlrdw's avatar

Also I believe they actually have a tutorial on installing laravel.

But irregardless make sure you point to public as the document root.

Also have you read the chapter in the documentation covering deployment?

1 like

Please or to participate in this conversation.