在Windows主机文件通配符 [英] Wildcards in a Windows hosts file
问题描述
我想设置我的地方发展机,以便为 *任何请求。本地
将被重定向到本地主机
。这个想法是,我开发多个网站,我可以再补充虚拟主机到Apache名为 site1.local
, site2.local
等,让他们都决心本地主机
,而Apache的相应服务于不同的网站。
I want to setup my local development machine so that any requests for *.local
are redirected to localhost
. The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local
, site2.local
etc, and have them all resolve to localhost
, while Apache serves a different site accordingly.
我在Windows XP上。
I am on Windows XP.
我尝试添加
127.0.0.1 *.local
我的 C:\\ WINDOWS \\ SYSTEM32 \\ DRIVERS \\ ETC \\主机
文件,也试过:
127.0.0.1 .local
既不其中似乎工作
Neither of which seem to work.
我知道我可以设置它们在不同的端口号,但是这是一种痛苦,因为它是很难记住哪个端口是哪个。
I know I can set them up on different port numbers, but that is a pain since it is hard to remember which port is which.
我不希望有设置一个本地DNS服务器或任何坚硬,有什么建议?
I don't want to have to setup a local DNS server or anything hard, any suggestions?
推荐答案
亚克力DNS代理(免费,开源)做这项工作。它创建了自己的hosts文件代理的DNS服务器(您自己的计算机上)。 hosts文件接受通配符。
Acrylic DNS Proxy (free, open source) does the job. It creates a proxy DNS server (on your own computer) with its own hosts file. The hosts file accepts wildcards.
从官方网站下载
<一个href=\"http://mayakron.altervista.org/support/browse.php?path=Acrylic&name=Home\">http://mayakron.altervista.org/support/browse.php?path=Acrylic&name=Home
配置亚克力DNS代理,从上面的链接安装它,然后去:
- 开始
- 程序
- 亚克力DNS代理
- 配置
- 编辑自定义HOSTS文件(AcrylicHosts.txt)
添加如下因素线路上的文件的末尾:
127.0.0.1 *.localhost
127.0.0.1 *.local
127.0.0.1 *.lc
重新启动DNS亚克力代理服务:
- 开始
- 程序
- Acrilic DNS代理
- 配置
- 重新启动亚克力服务
您还需要在您的网络接口设置来调整你的DNS设置:
- 开始
- 控制面板
- 网络和Internet
- 网络连接
- 本地连接属性
- TCP / IPv4的
设置使用下面的DNS服务器地址:
Preferred DNS Server: 127.0.0.1
的如果你再与jeremyasnyder的回答结合这个答案(使用 VirtualDocumentRoot
),然后你可以自动设置域/虚拟主机,只需创建一个目录。
If you then combine this answer with jeremyasnyder's answer (using VirtualDocumentRoot
) you can then automatically setup domains/virtual hosts by simply creating a directory.
这篇关于在Windows主机文件通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!