如何检查域名是否是PHP中的CNAME [英] How to check if a domain name is a CNAME in PHP

查看:142
本文介绍了如何检查域名是否是PHP中的CNAME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果访问该网页的网址是原始网址还是CNAME记录。

How do I check if the URL accessing the page is the original URL or if it's a CNAME record.

例如,我有一个网站 domain.com 。用户可以设置一个CNAME,它们将 www.otherdomain.com 链接到我们的网站 domain.com

For example, I have a site domain.com. Users can setup a CNAME where they link www.otherdomain.com to our site domain.com.

从我们的服务器角度来看,如何检测访问该页面的URL是否是实际的( domain.com )或者CNAME一个( www.otherdomain.com )?

From our server point of view, how can I detect if the URL accessing the page is the actual one (domain.com) or the CNAME one (www.otherdomain.com)?

推荐答案

我想你必须查询DNS才能知道,因为这些信息通常不会出现在请求头中。

I think you have to query a DNS to know it, since this information does not usually come in request headers.

看看 dns_get_record checkdnsrr 函数在PHP文档中。

Take a look at the dns_get_record and checkdnsrr functions in PHP documentation.

这篇关于如何检查域名是否是PHP中的CNAME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆