Skip to content

Instantly share code, notes, and snippets.

@trey
Created June 23, 2009 15:32
Show Gist options
  • Save trey/134595 to your computer and use it in GitHub Desktop.
Save trey/134595 to your computer and use it in GitHub Desktop.
Hostname switching in PHP, Python, and Ruby
$localServers = array('something.dev');
$stagingServers = array('something_else.com', 'and_another.com');
if (in_array($_SERVER['HTTP_HOST'], $localServers)) {
// Development settings
} elseif (in_array($_SERVER['HTTP_HOST'], $stagingServers)) {
// Staging settings
} else {
// Production settings
}
hostname = os.uname()[1].lower()
if hostname in ['something.local']:
# Development settings
elif hostname in ['something_else.com', 'and_another.com']:
# Staging settings
else:
# Production settings
# Ruby -- Use Rails
development:
# Development settings
test:
# Test settings
production:
# Production settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment