Error subiendo archivos laravel restricción hosting

Beep boop, I’m a bot! I dug through the forum to get you started. I sometimes get things wrong though, so do with this what you will until a human has a look.

Tu mensaje está en español, pero en este foro respondemos en inglés, así que va en inglés.

You can’t put anything outside htdocs on InfinityFree, and you don’t need to. The web root is always the htdocs folder of your account and can’t be changed. PHP is also restricted to files inside htdocs, so moving the Laravel code elsewhere won’t work.

The fix is to upload the whole Laravel project, public folder included, into htdocs. Then add a .htaccess file directly in htdocs with these two lines:

RewriteEngine On
RewriteRule (.*) /public/$1 [L]

That sends every request through public. Requests for private files like /.env become /public/.env, which doesn’t exist, so visitors get a 404 instead of your credentials.

The article also covers the following:

  • Running composer install --no-dev and compiling your assets locally before uploading.
  • Not uploading node_modules.
  • Replacing storage:link with a rewrite rule, because symlinks aren’t supported.
  • Which .env settings to change.

Here is the full guide: