# Sa \*\*Topic/Title\*\*, ilagay mo: \*\*\`Does InfinityFree support PHP environment variables and private c

**URL:** <https://forum.infinityfree.com/t/sa-topic-title-ilagay-mo-does-infinityfree-support-php-environment-variables-and-private-c/121148>\
**Category:** Hosting Support\
**Created:** [October 8, 2026, 5:16am UTC](https://forum.infinityfree.com/t/sa-topic-title-ilagay-mo-does-infinityfree-support-php-environment-variables-and-private-c/121148 "2026-10-08T05:16:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AldwinLomboy](https://forum.infinityfree.com/letter_avatar/aldwinlomboy/32/6_22734026db12803ebb3e059622ac3534.png) [@AldwinLomboy](https://forum.infinityfree.com/u/AldwinLomboy)\
**Post date:** [October 8, 2026, 5:16am UTC](https://forum.infinityfree.com/t/sa-topic-title-ilagay-mo-does-infinityfree-support-php-environment-variables-and-private-c/121148/1 "2026-10-08T05:16:23Z")

</div>

### Website URL

[https://tourismo.infinityfree.me/](https://tourismo.infinityfree.me/)

### Error Message

No error message. I am asking whether PHP environment variables, private PHP config files outside htdocs, or .htaccess SetEnv directives are supported.

### Other Information

I am not reporting a website error. I need to confirm the safest way to store production database credentials and other secrets on InfinityFree.

Please confirm whether my account supports:

1. PHP environment variables
2. A private PHP configuration file stored outside the `htdocs` directory
3. `.htaccess` `SetEnv` directives

I want to avoid storing sensitive credentials in publicly accessible files.

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [October 8, 2026, 5:16am UTC](https://forum.infinityfree.com/t/sa-topic-title-ilagay-mo-does-infinityfree-support-php-environment-variables-and-private-c/121148/2 "2026-10-08T05:16:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![KangJL](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/kangjl/32/12130_2.png) [@KangJL](https://forum.infinityfree.com/u/KangJL)\
**Post date:** [October 8, 2026, 5:19am UTC](https://forum.infinityfree.com/t/sa-topic-title-ilagay-mo-does-infinityfree-support-php-environment-variables-and-private-c/121148/3 "2026-10-08T05:19:56Z")

</div>

> [@AldwinLomboy](#):
>
> 1. A private PHP configuration file stored outside the `htdocs` directory

Not supported

---

<div class="post-metadata">

**Author:** ![Lemni](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/lemni/32/68303_2.png) [@Lemni](https://forum.infinityfree.com/u/Lemni)\
**Post date:** [October 8, 2026, 5:20am UTC](https://forum.infinityfree.com/t/sa-topic-title-ilagay-mo-does-infinityfree-support-php-environment-variables-and-private-c/121148/4 "2026-10-08T05:20:43Z")

</div>

_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._

I can’t confirm any of the three from what I found. Nothing in the knowledge base or the forum says whether PHP environment variables, a private config file outside `htdocs`, or `SetEnv` in `.htaccess` work on InfinityFree. I’d rather not guess on something that decides where your credentials live.

What I did find is a knowledge base article on installing Laravel. It says the web root is always the `htdocs` folder of your account and can’t be changed. It also says files in `htdocs` are reachable over the web unless you block them.

The article’s workaround is a rewrite rule in `htdocs/.htaccess`. Requests for sensitive files like `/.env` then return a 404 instead of the file:

> [@How to install a Laravel site on InfinityFree](https://forum.infinityfree.com/docs?topic=118578):
>
> Laravel is one of the most popular PHP frameworks, but it was not designed with regular shared web hosting in mind. Some parts of Laravel work out of the box on InfinityFree, some need a bit of configuration, and some features cannot be used at all. This article walks you through what to do, what to watch out for, and what you’ll need to work around. The document root problem When you install Laravel, you get a folder structure that looks roughly like this: my-laravel-app/ ├── app/ ├── bootstr…

That article is about Laravel, but the rewrite idea applies to any app that keeps its config inside `htdocs`. It doesn’t show that a location outside `htdocs` is usable, so it doesn’t answer your questions 1–3. If you keep secrets inside `htdocs`, check from a browser that the file actually returns a 404 and doesn’t show its contents.

You could settle the other two yourself with a quick test. Put a `SetEnv` line in `.htaccess` and read it with `getenv()` in a small PHP file. Or look at your FTP client’s folder tree to see whether you can create a folder next to `htdocs`. That would only tell you what works on your account. It wouldn’t be a documented guarantee.

---

<div class="post-metadata">

**Author:** ![Meishin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/meishin/32/59902_2.png) [@Meishin](https://forum.infinityfree.com/u/Meishin)\
**Post date:** [October 8, 2026, 5:49am UTC](https://forum.infinityfree.com/t/sa-topic-title-ilagay-mo-does-infinityfree-support-php-environment-variables-and-private-c/121148/5 "2026-10-08T05:49:27Z")

</div>

> [@AldwinLomboy](#):
>
> 1. PHP environment variables
> 2. A private PHP configuration file stored outside the `htdocs` directory
> 3. `.htaccess` `SetEnv` directives

None of them are supported on free hosting.

---

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [October 8, 2026, 10:46am UTC](https://forum.infinityfree.com/t/sa-topic-title-ilagay-mo-does-infinityfree-support-php-environment-variables-and-private-c/121148/6 "2026-10-08T10:46:53Z")

</div>

I’ve been told that some changes were made regarding private files outside htdocs folders. For _secondary domains_ (linked to their own domain folder, not to the main htdocs folder), PHP can now access files one level above their own htdocs directory. So they cannot read files from other websites on the same account, but you can store files safely outside of the htdocs folder.

If you are trying to set this up on a domain that’s currently assigned to the main htdocs folder, you can remove the domain from your account and then add it again to have it reassigned to a separate folder.

For environment variables, your best bet is to load a .env file. There is no way to configure environment variables that are automatically passed through to PHP.

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [October 15, 2026, 10:47am UTC](https://forum.infinityfree.com/t/sa-topic-title-ilagay-mo-does-infinityfree-support-php-environment-variables-and-private-c/121148/7 "2026-10-15T10:47:30Z")

</div>

Closed on October 15, 2026, 10:47am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
