Does infinityfree support .env outside htdoc folder

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.

No, you can’t put a .env outside htdocs on InfinityFree. Files created or uploaded anywhere other than an htdocs folder are deleted automatically, so the hosting won’t let you create it. The article below says so:

The usual workaround is to keep the .env inside htdocs and block web access to it. The Laravel guide on the knowledge base uses an .htaccess rewrite for this. Requests for /.env get sent somewhere that doesn’t exist, so visitors get a 404 instead of the file:

That guide is written for Laravel, but the .htaccess idea is the same for any app. If your app is plain PHP, tell me which framework or setup you’re using and I can look for something closer to it.