Configuring Wordpress for multiple environments

Send Snippet To: Save this snippet to Code Collector Pro -- view all mamok's snippets
language: Other
license: Other

Code for Snippet:

//The following code is added to the top of our wp-config.php:
// NOTE: lives outside webroot for additional security
// set the config file based on current environment
if (strpos($_SERVER['HTTP_HOST'], 'fuzz') !== false) {
    $config_file = 'config/';
elseif (strpos($_SERVER['HTTP_HOST'], 'viastaging') !== false) {
    $config_file = 'config/wp-config.stage.php';
else {
    $config_file = 'config/';
$path = dirname(__FILE__) . '/';
if (file_exists($path . $config_file)) {
    // include the config file if it exists, otherwise WP is going to fail
    require_once $path . $config_file;
comments powered by Disqus


Link to this snippet:

Download to Code Collector

To use the direct link to your snippet on either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 689
Date Added: 2013-10-24 11:21:47
Last Modified: 2014-04-22 23:06:37

Web Analytics