With long.rezo.net, you can now dereference those short URLs, and peek at the address they point to without actually going to it.
- Screenshot of the long.rezo.net website
In the “short url” input enter your short URL, and the site will indicate its destination address, with a link to it in case you want to proceed.
Bonus : your (long) address is checked on delicious and you will see its title and associated tags if it has already been registered.
How it works
The script that dereferences a short URL is a simple application of the HTTP protocol. The site calls the short URL, and checks if the headers contain a redirection line
Location: long address.
In PHP this is done with the following code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$a = curl_exec($ch);
if(preg_match('#Location: (.*)#', $a, $r))
$l = trim($r);
Going a bit further
I tried to find a method to go a bit further, because copy-pasting the short URL on the long.rezo.net website is not very convenient. To do it systematically, I toyed with my computer’s configuration.
HOSTS file (help) I’ve added the following line:
Then any call to one of those short URLs system is routed to my server at IP address
188.8.131.52, on which I’ve configured a simple mechanism to intercept those URLs, and proxy the others to their (legitimate) destination.
Her’s my apache configuration for these services:
Maybe a bit complex to install, this method enables me to get the long.rezo.net URL each time I click on a short URL, anywhere on my computer — in my email, in my twitter client, and so on.
You can use
184.108.40.206 if you wish to test, but I encourage you to install your own proxy, as my system is very much experimental.
If you have a better idea to do this, please indicate it in the forum below!