How to Create a Quick URL Shortening System on your website

URL Shortening services have create a great space on internet so far. Services like Bit.ly and TinyURL are big players. These services are free of cost and you can use them for any purpose. However some times we need something to rely and may be keeping things confidential. Whenever you create a short link on any 3rd party service, it is always being stored in their database and it also monitors the incoming traffic on those links. This is very good at some stage, however if you need to create something for the sake of security, confidential or anything you just don’t want them to keep, its not useful.

Recently I wanted to do something like that for my own and I didn’t want to use a third party service. So I decided to write a few lines of code myself which I can use for some printing and PDF files purpose. Below is a quick tutorial for you guys on how to do it at your own along with the zip file of code so you can re-use it.

Files we need

  1. index.php
  2. .htaccess
  3. short_urls.ini

Below are the sample codes for each file with some basic explanation

We will start with index.php

The code in index.php is the main one and is pretty simple. Takes you 3 minutes even if you write it from scratch.

Next file we need is .htaccess. Here is the code

So now the 3rd and last file we need is short_urls.ini which is fairly basic. You can add multiple lines with new keywords and full urls in front of them.

Demo / Example

Here is the working demo of this code can be found here. Short URL PHP Script – The URL can work with Google or Facebook keywords only. ie; copy and try in your browser. www.etechy101.com/shorturl/index.php?l=google

Download php short url script

Please leave your comments or feedback below if you like it or have any queries.

Looking for a quality hosting service? here are a few I suggest.
BlueHost | HostGator | Media Temple
Ali has been an entrepreneur in web, video and related technologies. Having worked with many business across the globe, Ali stands truly a great pillar in the business working with him.