Getting Shotgun to listen on multiple domains

Just a very quick one this week.

I wrote a 301 redirect inside my Sinatra app in order to send visitors from the www subdomain to the root domain, but how could I test this locally? I'm sure there are lots of ways to do this but I had a go at doing it using Shotgun as that's what I use in local development.

In my hosts file I have lots of domains directed at as I work with lots of Apache virtual hosts. I added another one for www.localhost . I then navigated to www.localhost in my browser but got a message saying that a connection to the server could not be made.

I thought this should have worked since the default host for shotgun to listen on is (like all those entries in the hosts file) but, apparently, that's not how it works. Instead I started shotgun listening on like so

shotgun -o

and then it did work. My app received the request and redirected the browser from www.localhost to localhost.

Addendum: I eliminated some complication by running shotgun on port 80 so that the URLs did not require an explicit port. I did this by shutting down Apache and then running Shotgun through rvmsudo.

Justin Hellings

"Justin? Hell of a guy! We would have kept him but you know how it is. Genius like that is always restless ... Eh? ... Oh, him ... No, I thought you meant someone else."

comments powered by Disqus