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.

Installation
To make "//wiki.ext/s/foo" work properly, you will need to set up rewrite rules for your webserver. Example rules for Apache are provided inside the extension.

Configuration

 * 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

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:

Rewrite rules
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: RewriteEngine On RewriteRule ^/s/(.*)$ /w/index.php?title=Special:UrlRedirector/$1 [PT]

This assumes your is set to /w.

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: