URL Shortening that Leaves the Shortened URL in the Address Bar

I'm building an internal URL shortening website for my company. Since so few people will use it, we're letting people choose their own custom shortened URLs. So, for example, you could have the shortened URL:


We thought it would be cool to offer, in addition to a regular redirect, the ability to leave the shortened URL in the address bar. One way to do this is with frames:

<frameset rows="100%,*" border="0">
  <frame src="http://some_really_long_url" frameborder="0" />
  <frame frameborder="0" noresize />

But this solution breaks links on the destination site (clicking one won't update the address bar).

What's the best way to accomplish this?

13.10.2009 23:34:20

You could write a pass through script that reads the destination url, and passes the contents back. I doubt it would be robust though. I doubt any solution to this would be robust. What is the purpose of this? And what's wrong with the frame?

13.10.2009 23:52:10
@recursive: What's wrong with the frame is mentioned by the OP: it "...breaks links on the destination site (clicking one won't update the address bar)."
Asaph 13.10.2009 23:54:10
The purpose is that it's more visually pleasing to see goto/toms-projects in the address bar than some_really_long_url_with_special_characters
Tom Lehman 14.10.2009 00:10:32
@Asaph: In what sense is that any more broken than the original concept?
recursive 14.10.2009 00:50:21
@Horace Loeb Why are you worried about how visually pleasing the address bar is? It's intended to be functional. People are entirely fine with long URLs in it.
ceejayoz 14.10.2009 02:00:19
@recursive: when the site is in a frame and the address bar remains constant as the user clicks around the site, individual pages are difficult to bookmark or email links to a friend.
Asaph 14.10.2009 02:27:02

Why not just do a server side include of the appropriate file/content instead of the redirect?

13.10.2009 23:52:13
Bad idea. What about relative URLs?
Tarnay Kálmán 3.11.2009 10:46:50
@Kalmi: I think this question was edited after I posted this answer. My answer made sense for the question as it was originally posted. In any case, I just posted another answer which is to use the html <base> tag to preserve the correct behavior of relative urls.
Asaph 3.11.2009 11:17:39

In order to preserve the original destination of relative links within the page, you could use the base tag.

         <base href="/original/really/long/url/" />
          <a href="relative-url.html">a happy relative link</a>
3.11.2009 11:14:46