I haven’t been busy lately so I thought this would give me some time to work on another project. This time the project was a link shortener which was coded in PHP and MySQL. The “Little URL Shortener” is all custom coded (except for a few parts) and the design comes straight from a PSD (which I have permission to use). All of my projects are open source, so of course this one is too. This time I have the code hosted on GitHub instead of Launchpad.

In order to use the Little URL Shortener, you need a web server that is able to run at least PHP v5.3 with the MySQLi extension, and also you will need a MySQL server. In order to install the script, first download the script from below and extract the files to your web server. Next, navigate to the install.php file (ie: http://mydomain.com/install.php) in your web browser. You will need a login configured for your MySQL server before you can proceed with the install. Once the install has completed, delete the install.php file (or rename it) and navigate to your website.

Although this script was done within the matter of only a week and a half, I did my best to make sure that it’s as secure as possible. Hence the reason why the script only works with MySQLi (because it’s securer then just the MySQL PHP extension and when used properly, there is no chance for SQL injection vulnerabilities). There are also checks to prevent CSRF (Cross-Site Request Forgery) exploits and many more other checks to stop hackers.

Depending on what web server (Apache, Nginx, LiteSpeed, Lighttpd, etc) you have, you will need to configure the rewrite rules so the short URLs (http://xyz.com/WH2o1e8) can be used. The rewrite rule is pretty much straightforward. I have included the rewrite rule for the .htaccess file if your using Apache below:

[highlight lang=”apache”]Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?code=$1 [R=302,L][/highlight]

I have already got a website setup and working with the project, you can go to http://www.7ls.net to check it out. You can register an account and test it out for yourself. It comes with API documentation that includes sample PHP code on using the API. You will also notice that the home page statistics are automatically updated using AJAX.

If you would like to give this script a spin, you can download it using the button below. Or, if you’d like to take a look at the code, you can check it out the GitHub repository. As always, if you have any questions or comments please post them in the comments below. Now it’s onto coding another Little Apps’ project…


Download Now:ZIP File

Download Not Available On Mobile Devices