Description  |  News  |  Contact  |  Downloads 


Summary | What is it? | Requirements | Installation | Usage | Limitations | License


UrlShortcut is a simple PHP script that let's you maintain a database of "shortcut" URLs.

This allows you to publish URLs to friends that are not extra long, with the purpose of either having easier to type URLs or simply to place URLs in email and avoid the URL being split on several lines. You can also use it as a repository of URLs to consult later or as a reminder of URLs to add to your favorite blog.

What is it?

UrlShortcut is a simple PHP script that let's you maintain a database of "shortcut" urls.
When a browser visits one of these short URLs, the PHP script will redirect the browser to the original URL immediately.

URL redirections can generally be setup directly in your web server's configuration (IIS, Apache, etc.). Unfortunately, this is generally a manual process that is hard to automatize and also requires administrator access to the web server computer and/or the web server account. On the other hand, UrlShortcut can be installed easily on any web server that has PHP support, such as home page typically provided by ISPs.


To use UrlShortcut, you need:

By default, the script uses the "db4" handler. This can be changed as described later.


Notes: this manual described steps for installation on a typical Linux box. Configuration on other systems should be similar. Please refer to your system maintainer or your operating system vendor for details.

To install, simply untar the archive under your public_html and rename the directory to what you want to see in the final URL. For example:

cd ~/public_html
tar xvzf UrlShortcut-1.0.tgz
mv UrlShortcut-1.0 url

This will make UrlShortcut available as the following URL:



The archive is composed of the following files:

  • common.php:
  Core functions and preferences.
  • index.php:
  Redirects to a pre-created URL.
  • create.php:
  Creates a new shortcut for an URL.
  • list.php:
  Lists all known shortcuts and their target URL.
  • template.htaccess:
  An example of .htaccess file that can be used with Apache to restrict access.
  • data/:
  Directory where the database file will be created and accessed.
Your web server must have write access to it.


Configuration is achieved by editing common.php and modifying the following defines at the top of the file:

DB_HANDLER preference:

DB_FILE preference:



The following discussion assumes UrlShortcut has been installed as described above and the service is available at the following URL:



1- Creating Shortcuts

To use UrlShortcut, you must first create a shortcut. You can do this by accessing the create.php script and providing the target URL directly on the query string, like this:


The URL must begin with "http://" to be accepted.

Since typing such an URL is annoying, the best way to create a shortcut is to place a bookmark in the toolbar of your JavaScript-enabled browser:

You will really enjoy and take full advantage of the simplicity of creating shortcuts once you take the necessary step to configure your web browser.

Once a shortcut has been created, a page will display the result shortcut, as this:

The following shortcut:


has been created and registered for the following URL:


List all existing keys

Alfray's UrlShortcut v1.0

The first link is what you want to use, copy/paste in emails, etc.

Note that UrlShortcut does not duplicate keys. If you try to create a new shortcut later with the same target URL, you will receive the previous shortcut URL. That means it is safe to call the creation script as many times as you want with the same target URL.

In the shortcut URL generated above, "1" is what makes the shortcut URL unique. This identifier is created by incrementally increasing a counter. The first value is 1 (the value 0 is never used). The counter value is encoded in base 34 using digits and lower-cap letters except letters "o" and "l" (L) which can be easily confused with 0 (zero) and 1 (one). If you need to memorize or write down the shortcut URL, the identifier is all you need.


2- Listing Shortcuts

Once you have created several shortcut URLs, you may not remember where each shortcut points to. The list page will show you that. It is available via a link at the bottom of the create page. To view the list, you simply need to browse this URL:


The result will look like that:

[1] => http://www.alfray.com/projects/UrlShortcut/
[2] => http://www.alfray.com/
[3] => http://www.alfray.com/projects/nerdkill/index.html
[4] => http://ralf.alfray.com/.izumi/

Alfray's UrlShortcut v1.0


3- Using Shortcuts

To use a shortcut, simply enter the shortcut URL in any browser. The script will order the browser to redirect to the target URL, if such a shortcut exists in its database. If not, the user will be presented with an informative message.

If the target URL is no longer valid, UrlShortcut still tries to redirect the browser to the specified URL. Depending on its configuration, the browser will display an error message indicating the page cannot be found.



UrlShortcut has the following limitations:



UrlShortcut is distributed under the terms of the General Public License (a.k.a. GPL).

I am not a lawyer and I find licenses generally obscure to read, so what it all means is:



March 21, 2004  

Version 1.0 completed and ready to download.




March 21,

Version 1.0 is the most recent stable & only revision.

[16 kB]
Development (a.k.a. unstable)

- - -





UrlShortcut is developed and maintained by



Alfray | Powerpulsar | R'alf Home Page
Last Updated: July 31, 2004
Created: March 21, 2004