Wednesday, November 9, 2016

Laravel in Shared Hosting - Complete Guide

Once you done with development in your local you might move the code to your hosting.
If it is shared hosting your entire laravel behaves differently than what you see in your local development machine.

Problems with Modifying .htaccess and removing public from URL
Simply because of the Security issues. Do you want to know how how many websites are vulnurable and Credentials are public?

Don't be part of it. Protect your .env file by maintaining the existing laravel 5.3 folder structure.

Removing /public from Laravel 5.3

First question is why you want to remove. Laravel works very well with its existing structure. Do not follow any techniques to remove the .htacess and server.php file (Server.php is not available in laravel 5.3)

All you need to do is modify the document root in your Shared hosting.

I use cPanel for this tutorial.

But if you already created a domain, you can modify its document root path easily.

Edit the Subdomain or Addon domain you need.

Add /public to the end of the URL to support Laravel existing folder structure

Now try to access your .env file it is not accessible for public.

Happy Laravel Coding.


  1. What if I have no access to my domain anymore

  2. Excellent tips. Really useful stuff .Never had an idea about this, will look for more of such informative posts from your side... Good job...Keep it up
    Laravel development UK |
    Laravel development company UK

  3. I couldn't resist commenting. Exceptionally well written!

  4. I like the valuable information you provide in your articles.

    I'll bookmark your blog and check again here frequently.

    I'm quite sure I will learn many new stuff right here!
    Best of luck for the next!