How To Create URL Shortener With Your Domain

Advertisement

We use shortening URL services like TinyURL, Bit.ly, su.pr, etc on daily basis. These services are great, but have you thought of creating something similar your own? Setting up such service on your own is fairly easy, and if you are using Wordpress it too comes with a plug-in that work seamlessly well.

YOURLS (Your Own URL Shortener) is what we’re talking about. It’s a free PHP script created by Lester Chan and Ozh Richard that allow you to create something similar to TinyURL and Bit.ly. We’ve installed and played around with it for a while, and here are our thoughts:

  • Easy to install – If you’ve got no problem installing Wordpress, then setting YOURLS is a piece of cake.
  • Customizable links – You can customize the links instead of the random characters that make no sense.
  • Statistics – An admin page that allows you to manage and keep track of details like date of creation, IP, clicks, etc.
  • Public/Private links- You control whether this service is available for public to use or yourself only.
  • Bookmarklet – Easy bookmarklet to create your own short URL on the fly.

YOURLS also comes with developer API as well as Wordpress plugin. If you like the idea of owning a private url shortening services, please read on. We’ll cover a simple guide on how to setup YOURLS.

First and formost

Here are some things you’ll need before the installation:

  1. A domain – A short one would be perfect but it’s hard to get these days. If you are thinking of getting a really short domain name, we suggest you try your luck on country code top-level domains like .at, .lv, .ly, etc with domain.nr.
  2. PHP Supported account YOURLS runs on PHP, so you will need to make sure the server (dedicated or shared hosting) supports PHP 4.3 and MYSQL 4.1 and above with mod_rewrite enabled.

Read more about YOURLS requirements.

1. Download

Download the latest version of YOURLS. Unzip it and fire up your favorite text editor. We are about to do some configurations.

2. Configure

  1. Look for includes/config-sample.php, rename it to includes/config.php and open up in editor.
  2. Mandatory settings you’ll need to change are: YOURLS_DB_USER, YOURLS_DB_PASS, YOURLS_DB_NAME, YOURLS_SITE. Last but not least, change your password for username and username2. The rest of the settings are optional. We suggest you go through the entire thing, it’s pretty self-explanatory. Please drop us a comment if you have problem filling this, or check out the YOURLS configuration guide.
  3. Create a database – Create a database with the name you’ve inserted for YOURLS_DB_NAME. If your web hosting account provide you with cPanel, login and find "MySQL Database" under Databases column.

    create database

3. Upload

Upload all files and folders in the exact same structure to the root folder of your web hosting account. Your root folder name might varies from public_html, www, html, etc.

upload to server

4. Install

We are almost done now. Fire up a browser, type in your domain name as url, follow by /admin/install.php. For example: http://yoursite.com/admin/install.php.

If everything is setup correctly, you’ll see these following messages with the link to your admin page at the end of the line.

yourls install success

5. Done!

Go on, login and start creating your very own short URL. Make sure you check out the Tools too, if you’d like to make a bookmarklet. Here’s a sample of how our YOURLS admin page looks like.

yourls sample

Hope it works for you, drop us a comment if you have any questions :-)

Related Contents

Sponsors

Posted by hongkiat in Tools , at 09.17.09

Tags: , , , ,

Comments

  1. abdusfauzi September 17th, 2009

    looks fun! but, i’m still searching for the need of having this service myself. i guess, not now. hehe.

    Reply
  2. Dushan September 17th, 2009

    nice post… I was wondering how these guy do the URL shorting you helped us

    Reply
  3. Melvin Foong September 17th, 2009

    I wonder, if MyNIC will allow sodo.my. THAT would be fun.

    Reply
  4. naz September 17th, 2009

    this is what I dream for lately! thanks =)

    Reply
  5. Prince of Andalus September 17th, 2009

    nice, great tutorial, i want to it soon

    Reply
  6. Sean O September 18th, 2009

    YOURLS is a great way to “install” your own URL shortener. For those interested more in creating their own from scratch using PHP & MySQL, check out my recent article:
    http://sean-o.com/short-URL

    Reply
  7. Blaineblogger September 18th, 2009

    Ok, that’s just cool. I’ll have to do it soon. Su.pr has a feature like this where you can get yourdomain.com/djd7f but I guess doing the above example you can get a keyword or two in.

    Reply
  8. Dinesh September 19th, 2009

    Same here

    Reply
  9. kahpeng September 20th, 2009

    Nice tutorial hongkiat, I thought want to come up with the How-to post, but here you done a good job here. I haven’t upgrade and play around with YOURLS version 1.4 beta with more cool stats.

    (Off-topic: Any1 interested to own WP.MY short domain ? =D Drop me an email with your offer @ http://scr.im/kp Thx!)

    Reply
  10. Dave Chonurous September 21st, 2009

    Great little tutorial. Check out this addictive game http://gumbota33.mybrute.com

    Reply
  11. Maulik Panchal September 21st, 2009

    Nice Posting : )

    Reply
  12. myklikers.net September 27th, 2009

    Nice one hongkiat. I been looking for this url shortener for a long time. Your post was resourcefull as always. love it!

    Reply
  13. Jayce September 29th, 2009

    Cool… Going to try it out. :)

    Reply
  14. Chamteh September 29th, 2009

    Just the one I was looking for. Made my job easy ;)

    Reply
  15. Honey October 2nd, 2009

    Thanks you ^.^

    Reply
  16. jason October 3rd, 2009

    wanted to register yum.my… but someone got it already. :(

    Reply
  17. maurice October 5th, 2009

    Check my project smrls – it allows anyone to get a url shortener – not only the people that own a domain! You can check it on http://smrls.net/ – feedback is really appreciated! :)

    Reply
  18. Saxaphone Lessons October 9th, 2009

    Peferct. This is something we’ve been looking at.

    Reply
  19. maurice October 18th, 2009

    it can be done easier. go to http://smrls.net/, think about a name for your url shortener, try to register that.. and you are done. you can create as many as you like, making it possible to create a shortener per subject you like let me know what you think of it via twitter @smrls. thanks!

    Reply
  20. fun games for kids October 19th, 2009

    It looks like pretty easy to setup even for php beginner. Thanks for the tutorial. Great post!!

    Reply
  21. Ling October 21st, 2009

    Thank you! Was looking for a free script that does url shortening and this post helps! ^^

    Reply
  22. TwitterPimper October 23rd, 2009

    Great article I have just put it on http://Okrati.me
    Thanks again…

    Reply
  23. opentube October 28th, 2009

    interesting article! But, we need to be cautious of what we shorten URL. Some time down the line, if we decide to stop, then all the older URLs need to be replaced :)

    Reply
  24. Nicolas Hoizey November 4th, 2009

    I created another project on this topic: http://cas.im/ir/

    Reply
  25. KevinChong December 3rd, 2009

    Ok, I will try it out later. It is seems cool and nice.

    Reply

Leave a reply