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

wadey's avatar

Deploy to Shared Hosting

Hi All

So i am on a shared hosting where I only have access to the public folder. I want to deploy my project to it, but you can see my problem. I've found the following SO thread (http://stackoverflow.com/questions/16683046/how-to-install-laravel-4-to-a-web-host-subfolder-without-publicly-exposing-app) which kind of helps, but it requires being outside of the public dir (which I can't).

So I'm wondering if I can put all my code in to the public folder, restrict all files using .htaccess except for the public directory, then just tweak the paths.php and index.php files?

Anyone got any ideas?

0 likes
4 replies
ovvessem's avatar
Level 49

Hi @wadey,

If you have no other option at your disposal to put everything in the public folder then you can limit the access with an .htaccess file and change the paths to the laravel public folder.

Another solution, if the CP of your hosting provider supports it, to change the default document root to the public folder of laravel. So that would be like /public/laravel/public/.

2 likes
wadey's avatar

Hi @pvvessem

Thanks for the reply. My shared hosting seems to be very awkward!!!! Thanks for the advice though.

wadey's avatar

One more thing @ovvessem :

if I structure my app like this: www (public root dir)-> laravel_code-> public-> (remaining files)

To reach my home page, a visitor would need to go to www.example.com/public/. How would I change this so they simply would need to go to www.example.com?

ovvessem's avatar

Hi @wadey,

You could move the entire application into the www folder (the DocumentRoot).

Now inside your www folder, place the following .htaccess file.

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

This should redirect all the requests to the Laravel public folder. Requests to your public folder to, for example, asset files will still be accepted.

Please or to participate in this conversation.