Host Your Own URL shortener (Tutorial)

Why you need you own url shortener

Links feed the web and short links make it a bit more pallatable, but why host your own?
Here are my reasons:

  1. I like to own my information and I want control. This is my business after all
  2. I want a simple control centre to host all my links
  3. I like to track my links and clicks to measure engagement and interaction
  4. I like to play around with things. I can’t code but I like playing with the end result (and I wanted to learn to use plesk too)
  5. I like the congruence it offers to my brand (and I’m vain)

Choosing the right url shortener

I’ve used a handful of different tools to manage redirections. They’re all decent and they all have drawback. For a while I’ve been using the wordpress redirection plugin to create sexy branded links to hide long ugly urls and affiliate links on my blogs. But each wordpress installation has it’s own install so I have multiple links for different domains. Then there are the links I have at bit.ly and TET. It’s a sprawing mess and I really need something more sophisti-ma-cated with better stats and an on-the-fly bookmarklet to do the wizardy stuff.

I tried a few options. TEtoolbox is probably the most powerful. You can use your own domain with some CNAME tweakery and a quick FTP but the most powerful tool is the ability to tag a short link (called a tracker) to track the specific traffic source. You can create a link to your site and append a tag like /twitter or /anythingyoulike to identify where the visitors are coming from. The only drawbacks are the inability to add a custom slug to replace the number it generates and having to login to the site to create new links. TEtoolbox is insanely good which is no surprise because Tim is a pretty shit-hot developer. But it’s a crying shame that it’s branded just for traffic exchange tracking. I’d love to see a white label version or an alternative front end to open up the market beyond the traffic exchange community.

…That and the slug thing.

Besides bit.ly, I tried Austin Hallock’s white label shortener. It has basic tracking and stats. Just load it onto your domain and get it working in about a minute. It’s a handy way to get started but still not 100% what I need. Then I discovered lessn (as used by Mailchimp = solid endorsement) and the updated lessnmore version but just couldn’t get it to work on my server. (probably my clumsy technical ineptitude).

So after reading around a bit, I settled on YOURLS. It’s open source, has a brilliant interface with a java bookmarklet to create custom links on-the-fly and it even has a wordpress plugin for the ultimate in branding and workflow simplicity. The only drawback is the lack of tagging which is a requested feature on the developers site so it might well happen.

How to get set up your own url shortener

Skillz – intermediate | Time – about 30 minutes

1. Buy a short domain name (optional – but nice)

I love domainr for hacking domain names. Just enter a word and it’ll generate cool url suggestions. I managed to secure shvl.me at Namecheap which links perfectly with the Silicon Shovel brand. If you’re really techy, you can even use symbols in your domain name but that was just one step too far for a novice like me.

2. Set up your hosting – just point your DNS settings in Namecheap to your nameservers provided by your hosting account. For example, bluehost use ns1.bnluehost.com and ns2.bluehost.com.

3. Upload a simple index.html file into the root of your hosting account so you can see when the site is ready to roll.

4. Download the YOURLS script and install it. Of course, there are gazillions of Youtube tutorials on how to do it. I followed this one to the letter and had no problems. The guy talks pretty fast so use the pause button. (He also pronounces the word “admin” as “atom” but he’s a smart kid so I’ll forgive him). The most important part I found was to make the changes to the config.php file (from sample-config.php) with database details and create login details before you upload it to the server.

Here’s the order:
create database *→ modify config.phpFTP to server

[*Bonus step – If you need help creating the MySQL database, watch this video for cPanel or this video for Plesk)

5. Go to http://yoursi.te/admin/install.php using the username and password you created in the datebase. If you see a prompt to create your own .htaccess file it’s nothing to worry about. Just create a text file in the same directory as the script files and enter the details from the developers wiki then raname it to .htaccess (no file extension). The leading period makes the file invisible so make sure you have the FTP setting to “show invisibles”.

6. Do the linky thing. Login at http://yoursi.te/admin using the username and password you created in the datebase and start creating your shortened links.

7. Setup your bookmarklet – In your admin panel goto ‘tools’ and drag the Advanced Bookmarklet to your browser toolbar and you can create links whenever you like (without visiting your admin panel).

Booyah – now to hook up WordPress

If you wanna get really fancy, you can install the YOURLS: WordPress to Twitter plugin on your wordpress blog.

8. Install the plugin as usual (here’s a video from Matt but I doubt you’re new to this). Activate it and go to Settings > YOURLS.

9. Fix the plugin the settings – the instructions are super-simple and they’d just be redundant here. You’ll need to create a new twitter app. If you’ve never done this, you won’t believe how simple it is and there even a help page inside the wordpress settings page showing you what details to enter. Then you just copy and paste some details from your twitter app page to the plugin in wordpress.

10. Close the loop, you can set the plugin to post a tweet (with your own shortlink) for every post you make in wordpress and it will show your blog name as the source of the tweet for extra branding mojo.

That’s all there is to it. It’s all copy and paste stuff so don’t be afraid to try it. And if you make a mistake, what’s the worst that can happen?

And all in 10 nice easy steps.

  • http://www.shaklee.net/results William Freeman

    Great tip and tutorial. I love to see step by step instructions and hyperlinks for additional information. I am bookmarking your blog and will revisit often.

    Thanks!!!

  • http://dnextra.com michele carr

    Well I gotta say I am glad I followed the link in the email note from marc eglon. I have been getting ready to dump all the subscriptions again. so I am glad you wrote when you did. Your name did not strike a bell in my memory.

    And two thumbs up for this post…..Gotta say I am impressed with the tute. Now I gotta go try it out, and I am the original technoidiot so if I can get through it anyone can.

    I will go do that now. I have been using bit.ly but it is hard to analyze the results in any real useful way. I am not sure that your program will work but it is better than what i am using and i appreciate your time spelling out the differences.

    I wish you had given some thought to the paid programs. The prices are all over and I don’t get a good handle on which ones are any good and worth the time to learn….

    thanks again,
    michele

  • Pingback: Tweets that mention Host Your Own URL shortener (Tutorial) — Silicon Shovel -- Topsy.com

  • http://dnextra.com michele carr

    Well my first rattle out of the box. i have a really short domain just sitting there. I bought it, heck I don’t know why, it was short and cheap and the name is easily remembered. TWTLAY.COM It almost suggests a porn site but now I know I’ll do the shortener. lets see tweet less at yours hmmm tweet long and yelling….tweet less among yours. well anyway

    do i put the index in the wp-admin file area? or somewhere else?

    i will go check out that video but that was the first stopping point. i would love any suggestions about that dang domain name.

    • http://siliconshovel.com Marc

      The index file isn’t strictly necessary but I just like to add my own placeholder so I can see when the DNS have settled and the site is online.

      But it needs to go into the root directory (home folder) which is usually called “public_html” in cPanel or “httpdocs” in plesk (ask your hosting company if you get stuck).

      wp-admin is a file created by wordpress when you install it so do NOT place the index file in there. In fact, you can’t run this script in the same directory as wordpress so if you want to run it on the same url, you’ll need to add it in a different folder.

      I recommend you use a single domain just for this script.

      And that dang domain name?

      It looks ok for this exercise although I don’t quite “get it”. But that’s not important. Depending on what you’re using the links for (posting to twitter, email etc) it should be fine. Can’t promise though – maybe spam filters will hate it? I really can’t say.

  • http://dnextra.com michele carr

    ok i watched him twice. i still don’t see where i ‘created a database’ you mention it too. is it the index.html file? I notice he talks about going into the html file but thank goodness it was a video and I could see he was going into the ….public_html….file. whew glad i caught that one. so anyway i am on for the third time and hopefully someone will answer here or i will get smarter.
    m

    • http://siliconshovel.com Marc

      Guess I left a gap in the process but I just added a bonus step at step 4 showing you how to setup the database. Hopefully this will make the process bulletproof so thanks for the feedback.

      This raises a couple more points in my mind now -

      1. If you ever get stuck with something – search on youtube. There are tutorials on anything you can imagine.

      2. Taking a small project like this on is a great way to learn how the web works. Play around. Try things. Make mistakes. build confidence. And you’ll You’ll be an expert in no time.

      3. I am certainly not an expert at this. I just sat down and taught myself how to do it. It took a little work to pull all the sources together but I did that so you don’t have to.

      4. It took me longer to write the blog post than it did to actually set up the site. You can do this.

  • http://www.andrewstark.com Andrew Stark

    Hi Marc

    I’ve been after a plug-in to replace tweet-my-blog to automatically tweet my blog posts. It’s not the easiest to configure, but I did manage it, and hopefully all my blog posts will now be tweeted with a shiny tiny.url

    Andrew

Previous post:

Next post: