Created
June 23, 2009 15:32
-
-
Save trey/134595 to your computer and use it in GitHub Desktop.
Hostname switching in PHP, Python, and Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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