Self Hosted Scripts for an URL Shortener: YOURLS

In Part 3 of this series of short articles on setting up your own URL shortener we turn to YOURLS, a very popular set of PHP scripts. YOURLS stands for Your Own URL Shortener, is open source and can be found on github.

Features of YOURLS

In contrast to the previously discussed software, YOURLS comes with a friendly and easy-to-use installer (requirements ATTOW: a server with mod_rewrite enabled, at least PHP 5.2, and at least MYSQL 4.1). Handy bookmarklets facilitate the easy shortening and sharing of links. Like, YOURLS comes with an API. Parameters are sent to http://your-yourls-domain.tld/yourls-api.php either via GET or POST (parameters must be URL-encoded if sent via GET).

YOURLS was developed with usage as a private interface in mind, i.e. with the intention that only the admin(s) can create short URLs for a registered short domain. Notwithstanding, it also supports the creation of a public interface. YOURLS provides awesome statistics including historical click reports, referrers tracking, and information about a visitor’s geo-location (see below).

Statistic pages can be configured for private access, such that only the admin(s) can access them, or for public access.

The perhaps most exciting feature is the plugin architecture of YOURLS, enabling all kind of mods and extensions to the default behavior—for a complete list, see the plugin list.

User Accounts and Responsiveness for YOURLS

Support for user accounts is currently only available via a rather outdated plugin called “Multi-User” by Matheus Bratfisch. This plugin works only with a certain development stage of YOURLS version 1.5. Therefore it needed a thorough refurbishment at the Labs before it could be used with YOURLS version 1.7.

ATTOW, in the releases up to the current one, YOURLS ships with a non-responsive design. However, a new design based on Bootstrap is already being worked at and can be tried out here. However note that, ATTOW, YOURLS version 2.0 (see a screenshot below) is not fully functional.

YOURLS 2.0 - Work in Progress

The URL Shortener Based on YOURLS

UPDATE: The article describes the former URL shortener Meanwhile, the domain has been sold, and the URL shortener service will not be continued. The script however still exists. If you are interested in purchasing it, go here. is a responsive URL shortener based on YOURLS version 1.7, built by The public interface page allows to use the convenient bookmarklets of YOURLS (see the following screenshot, taken after pressing the respective button).

The URL shortener, based on YOURLS

With the help of a heavily altered multi-user plugin, allows for registration of users. Every registered user can use an interface similar to that of the YOURLS admin —but only maintaining those long URL / short URL pairs belonging to that respective user, of course:

The user interface

The next screenshot shows the fields of the search form at the bottom of the user interface of

Search in the user interface

All pages, i.e. public interface, user interface, stats pages and help pages are responsive. If you are not on a mobile device right now, you can try that out by narrowing the browser window, e.g. like so:

Inside responsive design
Except for the added value of responsiveness, the design of the user interface stays very close to the original one in the current YOURLS releases.

The style of the side navigation is a citation of the one known from the Bootstrap docs. Like the original, it is featured by a scroll spy. However, unlike the side nav of the Bootstrap docs, it is turned to a top nav on mobiles (instead of simply turning it off).

It should be noted that also the table is fully responsive (a behavior powered by the footable jQuery plugin). Footable allows one to hide certain columns on smaller devices, but still allowing the user to expand each row to see the columns that were hidden. The responsive table of YOURLS 2.0 follows a similar principle. However, in contrast to YOURLS 2.0, where such an expansion is scheduled on hover of the respective row, footable expands on click/tap, which might make more sense on mobile devices.

The token can be used to authenticate an API access instead of passing a valid username / password pair.

The statistics pages of (see below) have a structure that is very similar to that of the original stats pages in YOURLS—except that they are now fully responsive, too.


The next part of our series of short articles gives a brief review of a self-hosted script for a pastebin, creating short URLs for the pastes. It is called PHP-pastebin.