Create your own URL Shortening Service

in Web



create your own url shortening service on your blog or website using this free scriptThere 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.

Like this? Share it with your friends!
  • Twitter
  • Facebook
  • Reddit
  • Google Bookmarks
  • Digg
  • StumbleUpon
  • Posterous
  • Tumblr
  • del.icio.us


Tags: , , , , , ,


Related Posts

{ 42 comments… read them below or add one }

1 aritra March 10, 2009 at 9:00 pm

Thanks soo much for finally coming up with the post .. :D

Will surely give it a try.

Thanks !

2 Harry March 10, 2009 at 9:12 pm

:)

3 Aravind Jose T. March 11, 2009 at 9:34 pm

Will try it out for sure.
Thanks.

4 Grace March 11, 2009 at 9:42 pm

Thanks for the script, will surely try it out :)

5 Ravi March 11, 2009 at 11:12 pm

awesome! thanks!

6 Aravind Jose T. March 12, 2009 at 2:32 pm

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 ? :D

7 Harry March 12, 2009 at 8:28 pm

Yes. A simple plugin can be written for this task! :)

8 David Catalano March 17, 2009 at 5:50 am

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!

9 Harry March 17, 2009 at 6:42 pm

Yeah I feel I must start writing some code again.

I’ll start working on the WordPress plugin soon and keep you guys posted! :)

10 Aravind Jose T. March 18, 2009 at 6:29 am

Voila !
All the best. Waiting for it, patiently :)

11 Stephanie April 9, 2009 at 9:39 pm

You rock! Seriously. Mucho Kudos. I’ll be sure to post once I get the script running. Also, you’ve just been favorited! :P

12 Lee April 20, 2009 at 11:15 pm

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?

13 Lee April 20, 2009 at 11:54 pm

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?

14 Harry April 21, 2009 at 10:54 pm

@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

15 Lee April 21, 2009 at 11:37 pm

Ah, that did it, Harry. Thanks! Excellent script.

16 Lee April 22, 2009 at 2:11 am

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.

17 Adrian April 22, 2009 at 7:23 am

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!

18 Harry April 22, 2009 at 8:32 pm

@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!

19 Lee April 23, 2009 at 1:54 am

Sounds great! Please be sure to post something here for the next release so we’ll all receive notice! Once again, excellent script!

20 Hecdias April 24, 2009 at 10:36 am

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!

21 Hecdias April 24, 2009 at 10:53 am

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!

22 Adrian April 25, 2009 at 2:41 am

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!

23 Harry April 26, 2009 at 10:07 am

@Adrian: That’s an awesome implementation! I love the design you’ve got there man!!!!

24 Richard Howell April 28, 2009 at 2:46 pm

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?

25 Fergus April 29, 2009 at 5:12 pm

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 :)

26 ECS Dave May 1, 2009 at 11:53 pm

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

27 ajay tanwer May 23, 2009 at 7:58 pm

tanwer

28 Dhruwal Patel July 28, 2009 at 4:20 pm

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 :)

29 Zrl July 28, 2009 at 7:34 pm

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.

30 Harry December 14, 2009 at 4:19 pm

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!

31 Zrl December 14, 2009 at 4:30 pm

Hey thanks, and good to see you back.

32 Lee December 14, 2009 at 8:17 pm

Ah, a holiday gift! Looking forward to it!

33 Adrian December 17, 2009 at 3:32 am

Excellent! I hope to see a bookmarklet! You have a donate button around here somewhere?

34 Harry December 17, 2009 at 3:15 pm

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! :)

35 Roland January 10, 2010 at 3:25 am

Dear Harry!

This script is great! :) Safety and quick!
When come the new version?

36 Roland January 11, 2010 at 9:32 pm

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

37 Gobbo January 22, 2010 at 7:46 pm

Hi,

If we want the public to access it how can we make it secure? So the db cant be hacked?

Gobbo!!

38 Lee January 22, 2010 at 9:32 pm

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

39 Harry January 22, 2010 at 10:23 pm

Great! Thanks! :)

40 dk123dk January 31, 2010 at 7:56 pm

thx you for your hard work i got a question how much msql doesthe script take

41 I need help!!! February 4, 2010 at 6:43 am

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.

42 Harry February 4, 2010 at 11:14 pm

Please check your .htaccess file.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: