PHP:使用Apache如何在本地搭建泛解析呢?
怪我咯
怪我咯 2017-04-10 14:44:58
[PHP讨论组]

目前我通过修改httpd-vhosts.confhosts文件,想要达到泛解析的目的。
但是在hosts文件中需要将要解析的域名事先写好。感觉这样子很麻烦,不知道有没有更好的实现方法呢?
httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "d:/www/"
    ServerName test.com
    ServerAlias *.test.com
</VirtualHost>

hosts文件

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

走同样的路,发现不同的人生

全部回复(2)
PHP中文网

你可以使用 dnsmasq 这个 DNS 缓存服务,它支持自定义泛解析,如:

address=/test.com/127.0.0.1
大家讲道理

在Hosts中直接绑定
127.0.0.1 *.test.com

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号