laraveldeploymentshared-hostingpublic-htmladdon-domain

Laravel 8 project deploy to shared hosting - security issues and public_html folder


I was able to deploy my laravel 8 application as and addon domain on inmotion shared hosting based on the following article https://medium.com/backenders-club/how-to-host-a-laravel-project-on-a-shared-hosting-via-cpanel-d955d32c528e

However, there are security issues with this as I can type mysite.com/.env and the file contents is listed in the browser showing the passwords.

I've tried many options to place the public folder of my laravel app into a public_html/public folder and none have worked for me. Anyone also getting this problem?

Addon domain Document root - /public_html/public
Laravel 8 application - /mysite.com (public folder contents moved to public_html/public)
Inside the public_html/public folder, the index.php file modified as follows:

require __DIR__.'/../../mysite.com/vendor/autoload.php';  
$app = require_once __DIR__.'/../../mysite.com/bootstrap/app.php';

In browser I get 'No input file specified.'


Solution

  • bad practice if you try to move files inside public folder to root directory , any one can view the files that exist in the root , my advice to you ,return your files to the public folder and use one solution from this :- first , you can make change the domain document root to public path second you can create .htaccess file in the root folder and contain this code :-

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