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?

https://www.google.com/search?q=intext%3ADB_PASSWORD+ext%3Aenv&gws_rd=ssl

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.

5 Comments

Previous Post Next Post