๐Ÿ”—

URL Shortener

Shorten a long URL into an easy-to-share short link.

โš ๏ธ This is a public URL shortener - anyone with the short link can reach the destination. Don't shorten links containing sensitive information.

How URL Shortener works

How does the URL shortener work?

On submit, the server validates that your input is a proper http or https URL, then generates a random 6-character code using PHP's random_int() and checks it against the short_links database table for collisions, retrying up to 5 times if needed. The code and target URL are stored in a MySQL table, and visiting /s/<code> looks up the row, increments a click counter, and issues a 302 redirect to the original URL.

When would I use this?

It's useful for turning a long, unwieldy URL into something short enough to share in a text message, print on a flyer, or read aloud, and the click counter gives you a rough sense of how many times the link has been visited. It works for any public destination but isn't meant for links that need to stay private.

Do I need an account, and do the links ever expire?

No login is required - anyone can create a short link, and the tool explicitly warns that the resulting link is public, so it shouldn't be used for URLs containing sensitive information. Looking at the database schema, there's no expiration field on stored links, so once created a short code stays active and redirecting indefinitely unless it's removed some other way.