URL Shortener’s are becoming increasingly popular on platforms like Twitter and Facebook, to share various news articles with your own URL instead of something like t.co, fb.me or bit.ly. They are especially popular with online magazines, who need all the click through’s they can get from Twitter and Facebook (aside: online magazines are becoming more and more prevalent with the young entrepreneur market – decide on a name, target market etc, buy a domain and hosting, and then either buy or design your own theme – see Magnate Magazine for a great example of an online magazine, run by some amazing young entrepreneurs. Even better, they're publishing offline magazines starting in a couple of months).
The method we are going to use requires a tool called YOURLS to be installed on your server, which means you need some web hosting. I say this because a lot of people assume it will all be done with various DNS type things but that is not the case at all. YOURLS is a set of PHP scripts that will be uploaded to your server that generate the links and work the magic to redirect your short URL to the real link.
Install and setup of YOURLS
So, the first thing you will need to do is download YOURLS from their downloads page (download the first one - yourls-x.x.x.zip
), and then unzip it.
Next, you will need to do a setup similar to WordPress - edit the database config file, which is found at /user/config-sample.php
. Change the file name to config.php
, and then you need to fill in:
- Your database details - (remember to create your database - you can do this using phpmyadmin or your favourite database management app.)
- The domain you are using as a short URL
- Fill in your username and after the double arrow (
=>
- a better name is the 'array value assignment operator'), put your user password.
Next, upload the files to your server (put them in your public_html
or www
folders - or wherever you would normally put your webpage scripts). Go onto your browser and go to http://www.yourdomain.com/admin
(assuming you installed YOURLS in the root folder on your server) and login using the username and password you specified above in the config.php
file.
You should then be logged in to the YOURLS system. You can make short links by typing in the box and hitting enter. Magic will be done and a short link will come out. Ta-da!
Assigning a random value instead of sequential
However, at first, the ending of the short URL will come out as sequential numbers - 1, 2, 3, 4 etc, making the URL http://www.domain.com/1
, which isn't the best short URL. There's a plugin that makes a random string of 5 characters instead. Also there's a list of known plugins on Google Code as well.
Enjoy!