I wonder how a URL Shortener works, like how they extract the text from address bar and map it to correct URL, later redirect it. What programming language do they use? How do they maintain the history of the mapping? How do they ensure the uniqueness of the shortened url? How can a lay man unmap it without visiting the URL?
When you use these URL shorteners, the shortened links will always point to the URL you set it to on a permanent basis (as long as the URL shortener stays in service and never shuts down).
The decision to shut down goo.gl and move to FDL is a result of changes in the ways that people share information online. In its effort to keep up with these changes, Google is moving to “smart URLs” that redirects users in a variety of ways that were not possible back in 2009. RIP Goo.gl URL shortener…
Bitly links never expire. If you use a custom domain to shorten your links they will continue to work as long as your DNS is still pointing at Bitly and the custom domain is attached to a Bitly account. While you can hide links and their analytics from the analytics view, the data will remain in Bitly.
URL shorteners work by creating a redirect to your long URL. Entering a URL into your internet browser sends an HTTP request to the web server to pull up a specific website. The long and the short URLs are both simply different starting points for an internet browser to get the same destination.
Wiki Is Your Friend
Basically, a website with a shorter name is used as a place holder, such as bit.ly.
Then, bit.ly generates a key for the user to provide, which is randomly generated to not repeat. With 35 character options and 8 or so values, do the math. That's a lot of possible keys. If a URL is equal to a previously existing key, I remember reading somewhere that they reuse keys as well.
They don't really use a specific programming language, they just use a simple URL redirect, which can be done with HTTP response status code 301, 302, 307 or 308, depending.
URL shortners just generate a shortcode, map the target URL to the shortcode, and provide a new URL. Visiting the URL performs a database lookup with the shortcode as a key, and redirects you to the target URL. There is no algorithmic association between a shortened URL and a destination URL, so you can't "unmap" it without going through the URL shortener's systems.
You can do it with any programming language and data store. Code generation is trivial to ensure uniqueness as well; if you had an incrementing primary integer key, you could simply encode the key as base62 and serve that. Since codes are incremental in nature, you'll never have a conflict.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With