Step 1. Enable mod_rewrite on your Apache web server.
Step 2. Create .htaccess file in root directory.
Step 3. Set Environment Variable by htaccess
SetEnv FIRSTVAR firstValue
SetEnv SECONDVAR secondValue
Step 4. Get Environment Variable using the getenv() PHP function
<?php
$firstVar = getenv('FIRSTVAR');
$secondVar = getenv('SECONDVAR');
?>
Step 5. Restart Apache Server
sudo service apache2 restart
Copyright ©2022 coderraj.com. All Rights Reserved.