General Musing

blaze your trail

Solving the URL shortening problem #twitter #tweet

leave a comment »

I don’t understand why url expansion after url shortening is such an issue that it needs to be implemented for each service separately. It relies on the same protocol HTTP and should be easy to reliably reverse this. Almost all url shortening services rely on 3xx redirection to forward the request using the Location header.

Using the example of the short URL for this post ““:

HEAD /phhhb-ul HTTP/1.1

HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 20 Apr 2010 18:22:53 GMT
Content-Type: text/html
Connection: close
Content-Length: 0

Specifically 301 is used as search engines – such as , Yahoo! and Bing – will index the real address rather than the shortened address. Naturally this can be done by a twitter client too.

A url can be put into this script which recursively checks the url. Example run:

$ php http.php
Connect to: (
Redirection to:
Connect to: (
Redirection to:
Connect to: (
Redirection to:
Connect to: (
True URL:

Quite simple really.

Written by Daniël W. Crompton (webhat)

April 20, 2010 at 8:10 pm

Posted in programming, risk, security

Tagged with , , , , ,

Please Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: