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