您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP:使用Apache如何在本地搭建泛解析呢?

2025/5/15 18:29:19发布16次查看
目前我通过修改httpd-vhosts.conf和hosts文件,想要达到泛解析的目的。
但是在hosts文件中需要将要解析的域名事先写好。感觉这样子很麻烦,不知道有没有更好的实现方法呢?
httpd-vhosts.conf
documentroot d:/www/ servername test.com serveralias *.test.com

hosts文件
127.0.0.1 1.test.com127.0.0.1 2.test.com127.0.0.1 3.test.com127.0.0.1 4.test.com127.0.0.1 5.test.com127.0.0.1 6.test.com127.0.0.1 7.test.com127.0.0.1 8.test.com127.0.0.1 9.test.com127.0.0.1 10.test.com127.0.0.1 11.test.com127.0.0.1 12.test.com127.0.0.1 13.test.com127.0.0.1 14.test.com127.0.0.1 15.test.com127.0.0.1 16.test.com127.0.0.1 17.test.com127.0.0.1 18.test.com127.0.0.1 19.test.com127.0.0.1 20.test.com127.0.0.1 21.test.com127.0.0.1 22.test.com127.0.0.1 23.test.com127.0.0.1 24.test.com127.0.0.1 25.test.com127.0.0.1 26.test.com127.0.0.1 27.test.com127.0.0.1 28.test.com127.0.0.1 29.test.com127.0.0.1 30.test.com

回复内容: 目前我通过修改httpd-vhosts.conf和hosts文件,想要达到泛解析的目的。
但是在hosts文件中需要将要解析的域名事先写好。感觉这样子很麻烦,不知道有没有更好的实现方法呢?
httpd-vhosts.conf
documentroot d:/www/ servername test.com serveralias *.test.com

hosts文件
127.0.0.1 1.test.com127.0.0.1 2.test.com127.0.0.1 3.test.com127.0.0.1 4.test.com127.0.0.1 5.test.com127.0.0.1 6.test.com127.0.0.1 7.test.com127.0.0.1 8.test.com127.0.0.1 9.test.com127.0.0.1 10.test.com127.0.0.1 11.test.com127.0.0.1 12.test.com127.0.0.1 13.test.com127.0.0.1 14.test.com127.0.0.1 15.test.com127.0.0.1 16.test.com127.0.0.1 17.test.com127.0.0.1 18.test.com127.0.0.1 19.test.com127.0.0.1 20.test.com127.0.0.1 21.test.com127.0.0.1 22.test.com127.0.0.1 23.test.com127.0.0.1 24.test.com127.0.0.1 25.test.com127.0.0.1 26.test.com127.0.0.1 27.test.com127.0.0.1 28.test.com127.0.0.1 29.test.com127.0.0.1 30.test.com

你可以使用 dnsmasq 这个 dns 缓存服务,它支持自定义泛解析,如:
address=/test.com/127.0.0.1
在hosts中直接绑定
127.0.0.1 *.test.com
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product