Apache logo. Copyright may apply. How to set an environment variable on Apache using .htaccess


Snippet

Setting an environment variable on an Apache HTTP server is a good approach to safely store variables and have access to them on a global scope. It is possible to set environment variables by writing the following line in a .htaccess file. This .htaccess file should be stored in the root folder of your wesbite.

apache
SetEnv VARIABLE_NAME value

Change VARIABLE_NAME with the variable name, and value by the actual value you want to assign it.

See also

How to fetch an environment variable in PHP