First of all you need to make sure that the Laravel project is outside of the public root and the .env file is not reachable.
Are you using shared hosting ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have already read a lot on the topic without having solved the problem... I'd like to deploy an old, simple Laravel 7.x project (working perfectly locally) on a remote server (shared at 'aruba.it') for testing purposes, maintaining the original structure of a usual Laravel installation.
I uploaded everything to 'https://www.mydomain.it/laravel/laravel-project', when asking for that I obtain '403 Forbidden'. When asking for 'www.mydomain.it/laravel/laravel-project/.env' I get the file view and I know this shouldn't happen... When asking for 'www.mydomain.it/laravel/laravel-project/public' I get 'www.mydomain.it/posts' with '404 Not Found' (in '/routes/web.php' I have 'Route::redirect('/', '/posts');'; and in any case I wouldn't want to add 'public' on the URL. As research suggests I placed '.htaccess' in '.../laravel-project' with this code: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ public/$1 [L] </IfModule>, at least I get the 'Not Found' Laravel's view... Maybe I'm doing something wrong in the '.env' file too? For example, what exactly should I write under 'APP_URL'? Thanks in advance, I'm a newbie.
Please or to participate in this conversation.