Does infinityfree support .env outside htdoc folder

Website URL

https://topten.infy.click/

Error Message

i want to secure my credentials by creating .env outsite the htdoc folder when i try to create hosting dosent allow to create is there .env file by default or it support any .env outside

Other Information

the .env is much safer outside the public folder so if there is any way to create please share your knowledge

Welcome to the InfinityFree community forum! Good to have you here.

  • Most people answering here are volunteers. They’re often the fastest source of help. Admin (the only staff member) checks in about once a day for issues on our end.
  • Volunteers can’t see your account or website. Share what you actually see, like error messages and what happens when you try something. That’s more useful than your theory of what’s wrong.
  • AI tools often get InfinityFree wrong. If a volunteer’s advice differs from what an AI told you, please try the volunteer’s suggestion first.
  • Solving an issue is a joint effort. Try the suggestions you get and report back what happened.

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.

The upload limit was recently loosened so that sensitive files can exist outside of htdocs only when the website have its own folder, so if your website locate in /example.com/htdocs you can put it in /example.com, but if you only have /htdocs then you are out of luck.