Tom Lehman
Tom Lehman

Reputation: 89203

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:

http://goto/toms-projects

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 />
</frameset>

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?

Upvotes: 1

Views: 609

Answers (3)

Asaph
Asaph

Reputation: 162801

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

<html>
    <head>
         ...
         <base href="/original/really/long/url/" />
         ...
    </head>
    <body>
          ...
          <a href="relative-url.html">a happy relative link</a>
          ...
    </body>
</html>

Upvotes: 3

Asaph
Asaph

Reputation: 162801

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

Upvotes: 1

recursive
recursive

Reputation: 86084

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?

Upvotes: 0

Related Questions