Knowledge base
1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Use the PHP environment variables (REDIRECT_)
This guide explains how to use PHP environment variables with Web Hosting that runs on php-fpm
.
Preamble
- PHP environment variables (
REDIRECT_
) are system variables used to store information about HTTP requests and redirects. - They are generally used on web servers to store details about previous requests or redirections that have been performed.
- The prefix "
REDIRECT_
" is often added to environment variables to indicate that they are related to specific redirections performed by the server. - These variables can contain information such as previous URLs, HTTP methods, or other data related to the client's navigation on the web server.
Using environment variables
To use PHP environment variables:
- Define the PHP environment variables in a
.htaccess
file:SetEnv EXAMPLEVARIABLE hello
- In your PHP file, the name of the variable to call must be prefixed with
REDIRECT_
:<?php getenv('REDIRECT_EXAMPLEVARIABLE');
In this example, the displayed result will be hello.
Going further with environment variables
It is possible to configure environment variables directly from the Manager for your entire website:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the concerned product:
- Click on Manage under Advanced settings:
- Click on the PHP / Apache tab.
- Click on the chevron to expand the Environment Variables section.
- Click on the icon Add.
- Enter the variable and its value.
- Click on the button to save:
Link to this FAQ: