How to check if a domain name is a CNAME in PHP

前端 未结 3 807
耶瑟儿~
耶瑟儿~ 2021-02-10 04:21

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

For example, I have a site domain.com. Users can setup a CNAME

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-10 04:47

    If you're checking on URLs, you can use $_SERVER['HTTP_HOST'] in PHP. That's the requested host from the URL (eg. http://otherdomain.com/blah.php would make the server var be otherdomain.com). $_SERVER['SERVER_NAME'] is the configured servername in the httpd.conf.

    If HTTP_HOST != SERVER_NAME, the remote user is almost certainly using an alias of some sort to access the site.

提交回复
热议问题