如何把通配符input到/ etc / hosts?
我最近想把所有的子域指向一个testing域,让我们说example.com到本地主机。 有没有办法将* .example.com上的所有请求都指向127.0.0.1
碰巧/etc/hosts文件不支持通配符条目。 
 你将不得不使用其他服务,如dnsmasq。 要在dnsmasq中启用它,只需编辑dnsmasq.conf并添加以下行: 
 address=/example.com/127.0.0.1 
下面是那些试图完成原始目标的configuration(通配符都指向相同的代码库 – 无需安装任何开发环境,即XAMPP)
hosts文件(添加一个条目)
文件:/ etc / hosts(非Windows)
 127.0.0.1 example.local 
httpd.confconfiguration(启用虚拟主机)
文件:/XAMPP/etc/httpd.conf
 # Virtual hosts Include etc/extra/httpd-vhosts.conf 
httpd-vhosts.confconfiguration
文件:XAMPP / etc / extra / httpd-vhosts.conf
 <VirtualHost *:80> ServerAdmin admin@example.local DocumentRoot "/path_to_XAMPP/htdocs" ServerName example.local ServerAlias *.example.local # SetEnv APP_ENVIRONMENT development # ErrorLog "logs/example.local-error_log" # CustomLog "logs/example.local-access_log" common </VirtualHost> 
重启apache
创buildpac文件:
保存为whatever.pac无论你想要的,然后加载浏览器的networking>代理>自动configuration设置(重新加载,如果你改变这个)
 function FindProxyForURL(url, host) { if (shExpMatch(host, "*example.local")) { return "PROXY example.local"; } return "DIRECT"; }