How To Create Your Own Tinyurl Style URL Shortener

yourls-logoA URL shortener is a service that takes in a long URL and gives you a short and memorable URL that you can distribute to anyone you want. The service takes care of redirecting users who land up at the shortened URL to the original URL.

TinyURL, of course, was one of the pioneers in the field but ever since Micro blogging sites like Twitter started to take off, a number of services have come up that all provide essentially the same URL shortening service.

One major problem with using a third-party URL shortening service is that all your links are always bound to that one service and if they ever go out of business, like tr.im did, all your data is gone too. And that is why, if you’re serious about saving all the wonderful links that you’ve discovered from around the web, you might want to consider running your own URL shortening service.

YOURLS gives you exactly that.

Installation

First of all, you need to download YOURLS to your web server and unzip the package.

yourls-download

Now, use your favorite tool to create a mysql database for YOURLS. If you’re using a shared hosting provider, there must be a way to do this from inside your domain control panel. If not, just open a ticket with your hosting provider and let them handle it for you. I named my database ‘kunz_yourls‘.

Now, browse over to the includes directory and rename the file named ‘config-sample.php’ to ‘config.php’.

Open ‘config.php’ in a text editor and edit the following variables.

‘YOURLS_DB_USER’
YOURLS_DB_PASS
YOURLS_DB_NAME
YOURLS_DB_HOST
YOURLS_SITE
$yourls_user_passwords

The comments in the file are pretty self explanatory and you can also get an overview here.

yourls-config

Now, from your web browser, visit the site http://<website>/admin, where website is the domain name where you installed YOURLS. Click the “Install YOURLS” button.

If all went well, you will see the following message which means that YOURLS was successfully installed on your domain.

yourls-install

Start creating your own Short URLs

Browse over to http://<website>/admin/index.php and login using the username/password combination that you entered earlier in config.php. If you didn’t enter any, try username/password. That’s the default combination and that is why you should change it when you’re installing YOURLS.

Upon login, you’ll be able to create short URLs easily by just entering the complete URL in the prominently displayed text box and clicking “Shorten the URL” button.

yourls-url

You can even get some nice and simple statistics about the short URLs that you’ve created.

yourls-stats

YOURLS also provides an API that you can take advantage of in custom applications and such.

Did you find YOURLS useful? Will you use it over, say, bit.ly? Let us know in the comments.

Sharninder

Sharninder is a programmer, blogger and a geek making a living writing software to change the world. His tech blog, Geeky Ninja, is where he shares his wisdom, for free !

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox