An Open Source Solution
To Self Hosted Link Shortening
One of the most common things online marketers need is a way to track and manage the links to content.
Creating tracking, shortening, and redirection links is a common request due to the utility of these tools… and the ability to change a URL’s destination after the link has already gone to publication.
A good URL shortener not only lets you shorten up long urls (perfect for twitter) but lets you retain some brand trust (via your custom URL). Additionally, the ability to change the destination URL means that if your location changes AFTER you publish them on business cards… no problem!
There are lots of ways to do this:
- WordPress Plugin PrettyLink and PrettyLink Pro [learn more]
- Bitly’s Custom URL Shortener [learn more]
- Premium Web Script “Easy Redirect Script” [learn more]
- and more..
Today we’ll take a look at the open source and free YOURLS self hosted web script!
YOURLS installs on any standard web hosting account and you will likely find an auto-installer (such as Softaculous) available for it in the cPanel of your quality hosting account.
Otherwise, you can just hop out to the website for the latest stable version, or out to GitHub for the latest draft, and install it like any other webscript.
A lot of the original core code was created by my colleague and team member, Nile Flores, before it was forked into this separate project. If you’ve hired my team to build or fix sites for you, you may have already met Nile!
Ajusting The Config File
Even if you install via auto-installer, there are going to be settings in the configuration file you are going to want to tweak by hand.
I edited mine to add a second user, to allow multiple short URLs to the same destination, and to use 64 rather than 32 base encoding. (You need to do the encoding stuff before you start making links – if you want to do it at all – or things are going to break.)
The core software is lean and stable and it really relies on on plugins to bring in the features you are likely expecting. Fortunately, there is a pretty wide range of YOURLS plugins available (free), although not all of them actually work currently so you may have to do some experimenting.
Plugins are installed by downloading their zip file and then uploading and uncompressing them on your hosting account. No small feat for novice web masters.
These are the plugins that I currently have installed – although only about HALF of them are activated – as most are situational.
I’ve had to uninstall several plugins that either did not work or did not “play well with others”.
Plugins I’m Using
|302 Instead + 301 for YOURLS URLs||Send a 302 (temporary) redirects that do not redirect to other short URLs and a 301 for YOURLS URLs
||BrettR / Tim Crockford|
|Allow Hyphens in Short URLs||Allow hyphens in short URLs (like http://sho.rt/hello-world)
|Bulk Import and Shorten||A YOURLS plugin allowing importing of URLs in bulk to be shortened or (optionally) with a custom short URL.
|Case insensitive YOURLS||Makes YOURLS case insensitive
|Don’t Log Crawlers||Prevents YOURLS from counting clicks of crawlers & bots with specific User Agent strings
|Don’t Track Admins||Short-circuits the yourls_update_clicks() function if the user requesting the link is logged in to YOURLS.
|Fallback URL||This plugin allows you to define a fallback URL in case there isn’t a match for your short URL, so you can specify something different than $YOURLS_HOME.
|Google Safe Browsing||Check new links against Google’s Safe Browsing service
|List Links||Shows an admin page that just lists your 1000 most recent links for quick viewing
||Ruth Kitchin Tillman|
|Mass Remove Links||Remove several (or all) links.
|Meta Redirect||use to redirect with meta tag by add _ (underscore) before keyword
|Popular Clicks Extended||A YOURLS plugin showing the most popular clicks for given time periods.
|Random Keywords||Assign random keywords to shorturls, like bitly (sho.rt/hJudjK)
|YOURLS Import Export||Import and Export the URLs
While the native YOURLS interface can be viewed from a mobile browser it is definitely cumbersome and not friendly. Fortunately, because YOURLS has an API, there is a YOURLS iOS app and YOURLS android app available. (These are third party apps, not created by the developer, but both seem to be working. )
Pros and Cons Relative To Other Options
- It’s free (Unlike PLP or ERS)
- It’s open source (Unlike ERS or Bitly)
- Reasonably flexible (Unlike Bitly)
- Can use any domain you own and can co-exist on the same domain as WordPress as long as it’s in it’s own folder or subdomain.
- Can change the URL destinations later (Unlike Bitly)
- Has customization plugins (Unlike Bitly or ERS)
- Can import and export (Unlike Bitly)
- Self-Hosted (so you OWN your data)
- Can add users (Unlike ERS and Bitly)
- Can set up a public-facing, public accessible link shortener (Like PLP, Unlike Bitly or ERS)
- It’s the most challenging of the four to install
- Not as many “fancy” redirect types (Unlike ERS)
- For redirects but not masking (Unlike ERS and Pretty Link Pro version)
- Self-Hosted (so you may not have as robust servers as Bitly has)
- No comprehensive backup available (import/export or database export are your only options)
- Design is basic (Unlike ERS)
As you can see – there’s a lot of items involved in the decisions about what is best for your business. If you only have a single website and domain to worry about, it’s best to stick with one alternative (or one self-hosted and one hosted such as Bitly).
However, generally you need to consider what is best for each of your business units.
I personally am using a combination of “all the above” on my personal sites and on client sites so I have the privileged of getting to stay up to date on all of the features… and to help you make informed decisions!
(My team and I also offer setup services for these for my clients, so don’t feel you have to do these installations all on your own!)
Enjoy YOURLS and feel proud that you’re supporting another great open source project!
~ Kim ~