Matthew Berman
Matthew Berman

Reputation: 8631

How do I get subdomains to work on my local machine?

I cloned a repo and am trying to get it to work. The app is very heavily dependent on subdomains. For example, signin.app.com or company1.app.com.

However, since I am trying to get it to run on my local machine, I can't simply do signin.localhost:3000

So, how do I get these subdomains to work using localhost?

Thanks!

Upvotes: 0

Views: 732

Answers (3)

Manish Shrivastava
Manish Shrivastava

Reputation: 32050

In linux

open command prompt >sudo vi /etc/hosts

Add a line in file

127.0.0.1 subdomain.hostname.com

and press Esc and :wq (means save host file)

thats it you type subdomain.hostname.com in your browser. Subdomain will run in localhost.

Upvotes: 1

Zubair
Zubair

Reputation: 238

As Gene said,

/etc/hosts file:- (add)

127.0.0.1 subdomain1.localhost

And on Rails3 this is treated as a domain, so you need to just add this:

127.0.0.1 subdomain1.localhost.local

then try, http://subdomain1.localhost:PORT

Upvotes: 1

Gene
Gene

Reputation: 4232

You could add the domain names to your hosts file, routing them to localhost.

Upvotes: 0

Related Questions