janes.hu logo
laravel shared hosting deploy

Deploy Laravel 13 to Shared Hosting Using public_html

By Janes Zsolt | 2026-05-10

Deploy Laravel 13 to Shared Hosting Using public_html

Learn how to deploy Laravel 13 on shared hosting using the public_html directory instead of Laravel’s default public folder. This guide covers Vite configuration, public path overrides, storage setup, and production-ready deployment tips for modern Laravel applications.

Running Laravel on shared hosting can be challenging because most hosting providers use a public_html directory as the document root instead of Laravel’s default public folder.

In Laravel 13, there are a few clean ways to handle this setup. In this guide, we’ll configure Laravel to use public_html as the public directory while keeping the application structure secure and maintainable.

Why Shared Hosting Is Different

On VPS or cloud servers, the web server usually points directly to Laravel’s public directory.

Shared hosting environments are different:

  • Your domain typically points to public_html

  • You usually cannot modify the server configuration

  • Access to Apache or Nginx configs is limited

  • The application files often live one level above public_html

A typical shared hosting structure looks like this:

/home/username/
├── laravel-app/
│   ├── app/
│   ├── bootstrap/
│   ├── storage/
│   └── ...
└── public_html/

Option 1: Point the Domain to Laravel’s Public Folder

Some hosting providers allow you to change the domain’s document root.

If possible, point the domain directly to:

/home/username/laravel-app/public

This is the cleanest and most secure solution.

If your hosting provider does not allow this, continue with the next option.

Option 2: Use public_html as Laravel’s Public Directory

Step 1: Override Laravel’s Public Path

Open the following file:

app/Providers/AppServiceProvider.php

Add this code inside the register() method:

public function register(): void
{
    $this->app->bind('path.public', function () {
        return base_path('../public_html');
    });
}

This tells Laravel to use the public_html directory instead of the default public folder.

Depending on your folder structure, you may need to adjust the path.

Step 2: Configure Vite

Laravel 13 uses Vite instead of Laravel Mix.

Open:

vite.config.js

Update the build output directory:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel([
            'resources/css/app.css',
            'resources/js/app.js',
        ]),
    ],

    build: {
        outDir: '../public_html/build',
        emptyOutDir: true,
    },
});

Now your compiled assets will be generated directly into public_html/build.

Build your frontend assets:

npm run build

Step 3: Update the index.php File

Copy Laravel’s default public/index.php file into:

public_html/index.php

Then update the paths:

require __DIR__.'/../laravel-app/vendor/autoload.php';

$app = require_once __DIR__.'/../laravel-app/bootstrap/app.php';

Adjust the folder names based on your actual directory structure.

Step 4: Create the Storage Symlink

Laravel needs access to public storage files.

Run:

php artisan storage:link

If your hosting provider does not allow symlinks, manually create the following folder:

public_html/storage

Then copy the contents from:

storage/app/public

Step 5: Check Your .htaccess File

Make sure your public_html/.htaccess file contains Laravel’s rewrite rules:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^ index.php [L]
</IfModule>

Without this configuration, Laravel routes may return 404 errors.

Security Recommendations

When using shared hosting:

  • Keep your .env file outside public_html

  • Never expose the vendor directory publicly

  • Disable directory listing if possible

  • Always use HTTPS

  • Regularly update Laravel dependencies

For production environments, also make sure:

APP_ENV=production
APP_DEBUG=false

Optimize Laravel before deployment:

php artisan optimize

Final Thoughts

Shared hosting is not ideal for Laravel applications, but it still works well for small projects, MVPs, and client websites.

If your hosting provider does not support changing the document root, using public_html as Laravel’s public directory is a clean and reliable workaround for Laravel 13 applications.

If you enjoyed this article, please share it so others can find it too

Janes Zsolt

Janes Zsolt

I am a Hungarian Laravel developer with over 10 years of experience, primarily focused on developing modern web applications. On a daily basis, I work with Laravel, Vue.js, various cloud and DevOps tools, as well as AI-powered solutions (OpenAI API). I have contributed to the development of everything from simple websites to complex systems, including e-commerce platforms and admin interfaces. Currently, I am continuously expanding my skills in AI, Python, and vector databases.

Keep Reading...

Discover more interesting articles