php - Find url and get ip address of website after redirect -


if have :

domaina.com/out.php :

<?php   header('location: http://domainb.com/'); ?> 

is possible url : domainb.com , it's ip address, domana.com/out.php domainc.com?

what want :

domaina.com/index.php

<?php    $data = geturlandip("domaina.com/out.php");    echo $data[0];  # wanted output (url) : domainb.com    echo $data[1];  # wanted output (ip) : 133.133.133.133 ?> 

if need redirects, can do

function getredirectstouri($uri) {     $redirects = array();     $http = stream_context_create();     stream_context_set_params(         $http,         array(             "notification" => function() use (&$redirects)             {                 if (func_get_arg(0) === stream_notify_redirected) {                     $redirects[] = func_get_arg(2);                 }             }         )     );     file_get_contents($uri, false, $http);     return $redirects; } 

this return array holding redirects last entry being final destination.

example (demo)

print_r(getredirectstouri('http://bit.ly/vdcn')); 

output

array (      [0] => http://example.com/      [1] => http://www.iana.org/domains/example/  )  

you'd have lookup ip's manually though (see other answers here) note redirect target doesnt have hostname. can ip well.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

c++ - How to test/verify that zero-initialization takes place -

node.js - Webpack/TypeScript Raising Errors When node_modules is Excluded -