I need to test sub-domains on my localhost. How can I effectively have this result of adding *.localhost.com to m /etc/hosts/ file?
If it's not possible, how do I work around this problem? I need to test wildcard sub-domains on my localserver. It is a Django dev server, can the django dev server handle the sub-domains? Can some other piece of software/routing give me the end result I want?
-
It is not possible to specify wildcards in the
/etc/hostsfile. Either specify the required hostnames explicitly or alternatively set up a local name server with the appropriate rules.From ar -
You cannot use a wildcard in
/etc/hosts. Have a look here for a good walkthrough on how to accomplish this using Apache: http://postpostmodern.com/instructional/a-smarter-mamp/Anonymous : Apache has nothing to do with subdomains.From Trevor -
Short answer:
Your /etc/hosts/ file won't let you use wildcards or port numbers. You will need to create one entry for each of your subdomain
ptman : What would let you specify port numbers? Not DNS AFAIK.From mplacona -
The short answer is you don't. The longer answer is you need to be clearer on what you desire to actually achieve, because there is perhaps either a better way, and a different way to achieve it.
For web-hosting (I've never seen it used otherwise) is done in DNS in combination with a virtual hosting aware web server. For more information on wildcard DNS records (Wikipedia), and an article Wildcard hosting with Apache and Bind for Linux using bind and Apache.
At worst, you could use a local DNS server I suppose.
From mctylr -
You need to set up a DNS server and have each client use it for resolution. The server itself can be something as "light" as dnsmasq or as heavy as BIND.
From Gerald Combs -
Install dnsmasq (I do this on all my Linux desktops as a DNS cache anyways). In dnsmasq.conf add the line "address=/localhost.com/127.0.0.1". Done.
JasonWoof : Thank you! I've been wanting this for years. It works wonderfully. Now I don't have to edit /etc/hosts every time I make a new website to test locally.From tomchuk
0 comments:
Post a Comment