Create a (free-ish) custom URL shortener
I, like many other people, recently created my own URL shortener that I use for links to pages on my website as well as sharing any other links I find. It was actually surprisingly easy to get setup thanks to a handy service called YOURLS, so I thought I would share the process here. There a number of reasons for setting up your own URL shortener, but in my case it came down to two things: tracking click stats and looking cool. Sure, after reading this post you will know how to create a URL shortener that you can even open to the public, but let’s be honest – the main reason for wanting to do this is for the geek-cred.
So here is a basic step-by-step on how to set up a URL shortener for yourself and potentially for public use too.
Get a short domain
The first step of course, is to register a short domain (hlash.me in my case). This is easy enough to get and can be done through any number of service providers. You will need to register a domain with hosting attached that has PHP activated on the server. You also need a MySQL database, but in my case I’m using this sites database so that wasn’t an issue for me. The domain registration and hosting is the only cost involved in the whole process.
Download and install YOURLS
Go to the YOURLS website and download the package. Once you have it, the only code you need to edit is includes/config.php – just setup the environment variable as required (this is very similar to setting up your a WordPress config file and is really straight forward to do). Once you have your code configured correctly simply upload the files to the root of your new domain and go to domain.com/admin/install.php – this will setup the necessary database files, YOURLS folders and .htaccess entries. From then on you just need to go to domain.com/admin to to administer your URL shortening service. You can use this dashboard to manually add URLs to shorten or to add a bookmarklet that lets you instantly shorten the URL of whatever page you are on at the time.
If you would like this service to be made public you can specify that in the config file. You can also use this dashboard to track the stats of your links to see when and how often they are clicked – gethering stats like this is obviously very valuable.
Integrate YOURLS with WordPress
This obviously only applies to people who have a WordPress site that they would like to integrate with YOURLS in order to have all their post URL automatically shortened and (optionally) posted to Twitter. All you need to do is to download the YOURLS (WordPress to Twitter) plugin and go through the simple configuration process to get everything sorted. The guide on the plugin page is more than sufficient for getting yourself setup, so I don’t think I need to repeat everything here. In the end your posts will automatically be supplied with a shortened URL and, if you like, they can be posted directly to Twitter.
So that’s it – easy, right?
Indeed, very useful and interesting writing. Thank you

I recently wrote about Displaying Advertisements before redirection in Yourls. You should read it.
http://taimoorsultan.com/show-ads-before-redirection-in-yourls/
Thanks! Happy New Year