Skip to content

Instantly share code, notes, and snippets.

@hasmanyguitars
Created August 15, 2014 22:30
Show Gist options
  • Save hasmanyguitars/fa7e5207c5065e515f2a to your computer and use it in GitHub Desktop.
Save hasmanyguitars/fa7e5207c5065e515f2a to your computer and use it in GitHub Desktop.
Local Subdomain testing
From 'http://matthewhutchinson.net/2011/1/10/configuring-subdomains-in-development-with-lvhme' for testing subdomains
#!/bin/bash
SUBDOMAIN=$1
TLD=$2
if [ $# -lt 1 ]
then
echo "which subdomain?"
read SUBDOMAIN
if [ -n "$SUBDOMAIN" ]
then
SUBDOMAIN="$SUBDOMAIN."
fi
fi
if [ $# -lt 2 ]
then
echo "which tld?"
read TLD
fi
echo "127.0.0.1 $SUBDOMAIN$TLD" >> /etc/hosts
echo "OK, added 127.0.0.1 $SUBDOMAIN$TLD to /etc/hosts"
Save this script as executable somewhere in your PATH, call it something like addhost then run it from anywhere like so;
> addhost # will prompt for subdomain, tld (leave blank for no subdomain)
> addhost www test.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment