Laravel: Using Alternative .env Files Based on HTTP Host
Sometimes you need to use different environment configurations based on your host. Here’s a simple solution to achieve this in Laravel. Implementation Add the following code to your bootstrap/app.php file, before the return statement: $envFile = ‘.env’; if (isset($_SERVER[‘HTTP_HOST’]) && str_contains($_SERVER[‘HTTP_HOST’], ‘alternativehost.test’)) { $envFile = ‘.env.althost’; } 🤓😎 More and more people are getting our
Laravel: Using Alternative .env Files Based on HTTP Host Read More »








