dns_get_record(): DNS Query failed
1、报错:dns_get_record(): DNS Query failed。如图1
1 | $records = dns_get_record( $host , DNS_SRV); |
2、打印 $host,其值为:https://object-wp.local/WP_ADMIN_USERNAME=admin
3、在浏览器中打开:https://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。但是确定 https://object-wp.local 是支持的。如图2
4、当以 http:// 开头时,仍然报错:Warning: dns_get_record(): DNS Query failed。如图3
1 2 3 4 | <?php $records = dns_get_record( $host , DNS_SRV); ?> |
5、在浏览器中打开:http://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。确定 https://object-wp.local 是不受支持的。WEB 服务器未监听 80 端口。如图4
6、参考可以配置一个同时处理 HTTP 和 HTTPS 请求的服务器。https://nginx.org/en/docs/http/configuring_https_servers.html 。
1 2 3 4 | server { listen 80; listen 443 ssl; } |
7、在浏览器中打开:http://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。但是确定 http://object-wp.local 已经是支持的。如图5
8、当以 http:// 开头时,仍然报错:Warning: dns_get_record(): DNS Query failed。
1 2 3 4 | <?php $records = dns_get_record( $host , DNS_SRV); ?> |
9、当不以 http:// 开头时,仅剩下纯粹的域名,不再报错。结果为空数组。
1 2 3 4 5 | <?php $host = 'object-wp.local' ; $records = dns_get_record( $host , DNS_SRV); print_r( $records ); ?> |
1 2 3 | Array ( ) |
10、当不以 http:// 开头时,仅剩下纯粹的域名,且去掉参数:DNS_SRV。不再报错。结果不为空数组。如图6
1 2 3 4 5 | <?php $host = 'object-wp.local' ; $records = dns_get_record( $host ); print_r( $records ); ?> |
1 2 3 4 5 6 7 8 9 10 11 12 | Array ( [0] => Array ( [host] => object-wp.local [class] => IN [ttl] => 604800 [type] => A [ip] => 127.0.0.1 ) ) |
11、由此可以确认,程序代码的处理逻辑上存在一定的问题。至少说明其是不支持 https:// 的相应配置的。
近期评论