Link shorteners are a dime a dozen. Even Google and StumbleUpon have joined the fray, because a shortened URL doesn’t just look good. They also go a long way to improving the usability of links. Even if you’re not limited by 140 characters, shortened links are easier to remember, and it keep your shares, and those of your readers, uncluttered.
If you have your own website, you can get by with using a popular URL shortener like [NO LONGER WORKS] TinyURL or bit.ly. However, with your own domain, there’s little reason not to set up your very own URL shortener. Hosting your own URL shortener has a number of advantages for any site owner. Apart from the added control, it’s also a matter of branding. You’re constantly building on the image of your site, and your own URL’s make up a nifty part of that image. It adds recognizability and helps non-frequenters remember the name of your site.
These self-hosted shorteners fall into two broad categories. With a private shortener, only the owner of the website is able to create new short URL’s – this is ideal for a content-based system, like a blog, a forum, or a company website. Whether a gimmick, or an integral part of your website, everyone can use a public shortener to compress additional URL’s, effectively creating your own TinyURL or bit.ly lookalike.
In both the cases outlined above, YOURLS is your go-to guy. This set of PHP scripts allows you to quickly and easily install a customizable URL shortener on your website, complete with bookmarklets and WordPress integration. We’ll walk you through the process.
We will assume you already have your own server space. If not, take a look at James’ explanation on The Various Forms Of Website Hosting, the results of our Poll: Which Is The Best Budget Web Host?, or Danny’s guide on How To Set Up An Apache Web Server In 3 Easy Steps for a locally hosted server.
When you’re picking a potential candidate, keep these YOURLS server requirements in mind:
- A server with mod_rewrite enabled.
- PHP support (version 4.3 or higher).
- MySQL database support (version 4.1 or higher).
Step 1: Download & Extract YOURLS
Download the latest version of YOURLS and extract it in a place you can easily reach on your computer.
In this folder, copy ‘/includes/config-sample.php’ to ‘/user/config.php‘.
Step Two: Fill Out Your Server Details
MySQL will need a database to work. If your server meets the requirements, you can usually create one in your host’s administration panel with a few clicks of the mouse. This is also where you’ll be able to find the database name, URL and access credentials.
The server host field can usually remain at ‘localhost‘, unless otherwise specified by your web host. If you’re stuck, look at your host’s help files, or contact support.
You’ll also need the URL of your website. Mind you, this is not necessarily your root domain name. If you’ve already installed something on your root domain (like a blog), you’ll have to put YOURLS in a sub-folder. The path of this sub-folder will determine the URL of your YOURLS site. For instance, if you install YOURLS in a folder /s, the URL of your YOURLS site would be http://your_domain_name.com/s .
Open the file you’ve just copied ( /user/config.php ), in your favorite text or code editor. You can use Notepad or TextEdit on Windows or Mac OS X respectively. Now, replace the corresponding fields in this file with the database credentials and the URL you just found and hit save. Scrolling down, you can find a batch of other options in this configuration file. You can customize these to your liking, or stay with the default configuration.
Step Three: Upload The Files To Your Server
Next, we’ll upload the unzipped YOURLS files to your server. You can use an FTP client (again, getting the FTP credentials from your web host), or use your web host’s online file manager to do so. You’ll have to upload these files to the folder you specified as the YOURLS installation URL in the previous step. This will likely be in ‘/www/your_folder‘ or ‘/public_html/your_folder‘.
You can now point your web browser of choice to your_domain_name.com/your_folder/admin/ to finish the configuration.
Step Four: WordPress Integration & Other Plugins (Optional)
If you’re using YOURLS in conjunction with WordPress, the fun doesn’t have to stop there. YOURLS has released a WordPress plugin that allows you to integrate your URL shortener with your blog. Using this plugin, you can automatically shorten the links of your newly published blog posts, and even post them directly to twitter.
However, you aren’t limited to WordPress. On the YOURLS site, you’ll be find an ever growing list of plugins. You can use these to integrate with Google Analytics, Tumblr, or automatically generate QR codes, just to name a few.
Where are you going to use your personal URL shortener, and how? Let us know in the comments below!