Extension:UrlShortener

The UrlShortener extension provides a basic URL shortening service as a MediaWiki extension. It will require some changes to your web server's configuration to operate properly. It was originally designed to implement the URL Shortener RfC.

For user documentation, see Wikimedia URL Shortener.

LocalSettings.php

 * URL routing configuration

Configures the template to use when generating the shortened URL. Using this feature will require mod_rewrite (or an equivalent). If set to false (default), the short URLs will use the not-so-short  since it will work regardless of web server configuration.

If you wanted your short URLs in the form of, you would set:

Set this to the name of a database if you wish to use one central database for your wiki farm. If set to false (default), it will use the wiki's normal database.
 * Global database

Configures the acceptable domains that users can submit links for. This is an array of regular expressions. If set to false (default), it will set up a whitelist for the current domain (using ).
 * Whitelist regex

For example, to only whitelist links to wikipedia.org or wikimedia.org, we would use the following:

If we wanted to whitelist any domain:

VirtualHost or .htaccess
To have truly short URLs, you will need to set up rewrite rules, using mod_rewrite or something similar. An example of what to put in your  file comes with the extension. If our template was set up to, then we could use:

If you are using nginx, you can add the following within a  definition.

This assumes your is set to.

API
This extension provides the API module  to get the shortened url for a given url, creating it if does not exist already.


 * - URL to shorten.

Response: