There are a plenty of URL shortening services around that are both free and easy to use. URL shortening services are highly important when you have to share an interesting link with your friends or contacts online and don’t want to pass on an ugly URL which might just get chopped off at the other end, rendering it useless. URL shortening services such as TinyURL have become highly popular in the recent past. It becomes easy for one to share a link online be it on Facebook, MySpace or Twitter using a URL shortening service. So I was just wondering if I could have my very own URL shortening service which I could use personally or allow visitors on my blog to use it. So I Googled for a while and picked up a tiny class written in PHP, modified it as per my taste and bang! I have my very own URL shortening service here called Linx! Some of my friends were interested in applying this on their blogs/websites as well so I have decided to put it up here.
First of all, if anyone of you is wondering why I should have my own URL shortening service. Well here are a few good points;
- Every time you find an interesting link you want to share with your friends and if your link looks something like http://yoursite.com/1, you’re not just passing on a link but you’re passing on your website name. Publicity!
- Links are destined to go viral. So if around 1000 people love the content, they’ll pass on the link further. If even 2% of them case about the yoursite.com part, bang! You’ve got traffic baby!
I’m sure there are a plenty of more reasons you’ll find to suit your needs. Anyways here’s all the information on the script part you’ll need to get started.
HarryJerry Linx 1.0
What is this script all about?
- HarryJerry Linx is a simple script written entirely in PHP and uses a MySQL database to create short URLs out of big bad ugly ones.
- It produces URLs of the form: http://yoursitename.com/p
eg. http://linx.harryjerry.com/p
How to download the script?
- Click here to download the HarryJerry Linx script. It’s tiny (just a little over 5KB) and won’t take more than a second.
How to install the script?
- There’s a nice little shiny page included with the script, titled ‘Read me’, and it’s really great if you read it. I have included all the installation steps from a very basic point of view. It’s very easy to install and takes only 5 minutes.
What are the minimum system requirements?
- You’ll need a web hosting account with PHP/MySQL support. That’s it!
How about support?
- In case you face any problems you can post them here (on the comments section), e-mail me at harryjerry21@gmail.com, contact me on Twitter (harry_jerry). I can also offer you free installation services, just in case.
Future Development
I have a few more ideas on this script. I’ll be working on them regularly and updating the script to add extra functionality. In case you like Harryjerry Linx, please post your feedback.
Tags: downloads, free, mysql, php, script, tinyurl, url shortening

{ 42 comments… read them below or add one }
Thanks soo much for finally coming up with the post ..
Will surely give it a try.
Thanks !
Will try it out for sure.
Thanks.
Thanks for the script, will surely try it out
awesome! thanks!
Harry,
For a project of mine, that will be powered by wordpress, it would be great, If the script could produce a shortened URL for every post, when it is published.
Am I asking to build Google ?
Yes. A simple plugin can be written for this task!
Ditto on the Wordpress plugin. That would be fantastic. My company already has a short URL so we just need a script like this and we’re good to go.
thanks!
Yeah I feel I must start writing some code again.
I’ll start working on the WordPress plugin soon and keep you guys posted!
Voila !
All the best. Waiting for it, patiently
You rock! Seriously. Mucho Kudos. I’ll be sure to post once I get the script running. Also, you’ve just been favorited!
Great script. Just two questions (I’m not real experienced with databases):
1. Is there a way to administer the links, e.g., delete them, see which is which so they can be re-used later?
2. Is there a way to make the created link work off the main domain without including the subdirectory, e.g., http://example.com/p2 instead of http://example.com/linx/p2?
And now I am getting the following error:
Warning: Cannot modify header information – headers already sent by (output started at /home1/shamaror/public_html/emet/r/includes/conf.php:1) in /home1/shamaror/public_html/emet/r/index.php on line 82
Any ideas what is wrong?
@Lee: I guess you edited the script using Notepad. Make sure there are no blank lines at the end of the script files. Now do a re-upload and it should work fine.
As of now you can’t have links outside the subdirectory. I’m working on another edition of the script which shall allow this feature.
Thanks
Ah, that did it, Harry. Thanks! Excellent script.
One other question. Is there a way to stop others from finding/using the script? I tried a password but then, of course, that required anybody who wanted to use the short URL to know the login also.
Simple, easy to install & use script here. Props! One question: is it easy to create a bookmarklet for this – similar to tr.im’s? People could drag it into their bookmark bar and click it whenever they want to shorten a URI with your Linx installation.
Thanks!
@Lee: Yes you can’t simply apply a password like that, I’ll include this feature in the next release for sure.
@Adrian: Thanks for the feedback! Yup that’s a great idea, a bookmarklet would be great!
Sounds great! Please be sure to post something here for the next release so we’ll all receive notice! Once again, excellent script!
Hi, I got these errors when trying to create my first URL:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/moses/public_html/harryjerry-linx/includes/hjurl.php on line 19
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/moses/public_html/harryjerry-linx/includes/hjurl.php on line 73
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/moses/public_html/harryjerry-linx/includes/hjurl.php on line 123
Any help would be greatly appreciated.
Thanks!
Hi,
I actually figured it out, I imported the SQL table file to the wrong database
Just wondering for SEO purposes, are the redirect links 301 or 302? If they are 302 can we change them to 301 somehow?
Thanks again for this wonderful script!
Okay, you can see Linx in action here: http://133t.us
It’s not quite complete, and I will be including a mention to you Harry. Am looking into a bookmarklet and a few other things for ease of sharing.
Thanks again!
@Adrian: That’s an awesome implementation! I love the design you’ve got there man!!!!
I have uploaded your script and added the database to the SQL database when i create my link the data is inputted into the SQL database but when i try and visit a URL i have shortned i get a 404 error. I am not really sure why any ideas?
Great script Harry! Thanks
just one question – my shortened URLs are coming out as //1 or //2 etc. They still work as I have fiddled with the htaccess but any ideas on how to stop this happening? Thanks
Can the shorturl script be customized to change a parameter to only a single address?
Instead of “any” url, the shortened url would be a predetermined one, with the “customization” being parameters added to the predetermined url.
Such as: http://test.com/?TheParametersGoHere
to be shortened to the shorturl…
Thanks!
ECS Dave
tanwer
if anyone has problem with // showing in URL like ‘Fergus’ has above (comment 25), then open index.php and look for:
if ( REWRITE ) // mod_rewrite style link
{
$url = ‘http://’.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']).’/’.$lilurl->get_id($longurl);
}
remove / from betweem .’/’. and save the file.
If someone has problem with site not working, or url’s not working then replace all the content in .htaccess file with this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
happy shortning or urls
Another implementation of your script.
http://zrl.in/
Thanks for great script.
Few Features if you can code:
1. Check if URL is in proper format or not
2. Number of hits on each URL
3. Option to enable/disable CAPTCHA
4. When new short URL is generated, automatically copy it to Clipboard.
5. One admin page, where there is a grid which will list all the URLs.
Would appreciate it. Thanks.
Thanks for the support guys! Some lovely implementations I’ve seen. I’m working on an update now, keeping in mind some of your suggestions. I’ll be posting it online soon.
Thanks again!
Hey thanks, and good to see you back.
Ah, a holiday gift! Looking forward to it!
Excellent! I hope to see a bookmarklet! You have a donate button around here somewhere?
Thanks Adrian! In fact I’m currently testing the bookmarklet feature only. Yes I have a donation button, it’s on the about me page.
http://harryjerry.com/about-me/
Thanks again!
Dear Harry!
This script is great!
Safety and quick!
When come the new version?
Dear Everyone!
If problem the css, js, etc… query in the index.php write this line in the .htacces file:
RewriteCond %{REQUEST_FILENAME} !-f
and voila!
Best: Roland
Hi,
If we want the public to access it how can we make it secure? So the db cant be hacked?
Gobbo!!
Just a note, Harry. I wrote a short article on the installation of the script, a bit more detailed than yours. It’s here: http://linx.harryjerry.com/wt
Great! Thanks!
thx you for your hard work i got a question how much msql doesthe script take
If you add a URL at my site: http://marksiforum.com/URL/ When I click one of the links I get a 404, please email me so you can help.
Please check your .htaccess file.