Skip to content
A cgi script for shortening urls and managing bookmarks
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

A cgi script for shortening URLs and managing bookmarks.


This script generates a very basic basic web page to shorten URLs. Drop the file in your cgi-bin directory and setup a directory and the script does all the work.

The script also supports personal bookmarks. Using the accounts on your server, users can login, shorten URLs and add names and tags.

Everything in the script is basic shell and system commands. User accounts are those on your server. Databases are two flat files, one to hold cookies and one to hold links. Keep it simple.


Setup a directory to store the database information. Permissions should be set to your cgi/web account.

# mkdir /var/lib/
# chown http:http /var/lib/
# chmod 700 /var/lib/

Next drop the script into your cgi-bin directory. Modify the configuration and change it's permissions to executable.

# vim /srv/http/cgi-bin/
# chown http:http /srv/http/cgi-bin/
# chmod 700 /srv/http/cgi-bin/

Once the options are configured (see section below) you can add users via the command line. Once user is created they can change the password once logged in.

# /srv/http/cgi-bin/ adduser foo bar

If the password is lost, just run the same command to replace with a new password.


# Path to store database info

# Title of page

# Faull URL path. This is used in the HTML generation, all forms will
# point to this path

# Login expiration (in seconds)
EXPIRATION=3600 # 1 hour

# Expand delay (in seconds)

# Enable User accounts
# This allows the script to run as a bookmark app as well
# as a URL shortener. If you just want a shortener set to
# false.

# List of users that are not allowed to log into this service
BLACKLIST=(root http nobody)

License and Acknowledgements

This script uses bash_cgi created by Philippe Kehl. See site for more information.

The rest of this script is released under the New BSD License

You can’t perform that action at this time.