Find url and get ip address of website after redirect

后端 未结 3 461
一整个雨季
一整个雨季 2020-12-21 06:14

If I have :

domainA.com/out.php :


Is it possible to ge

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-21 06:40

    Use get_headers() to get the http headers from a URL.

    Something like this should work to get the domain name.

    $headers = get_headers('http://domaina.com/out.php', 1);
    echo $headers['Location'];
    

    To resolve the IP address, look at the gethostbyname() function.

    echo gethostbyname($headers['Location']);
    

提交回复
热议问题