Skip to Content
PluginsShort Links

Short Links

A Moodle URL shortener plugin. Generates short links that redirect to a user-specified destination URL.

How it works

Users create short links via the plugin’s web interface (accessible at /local_shortlinks). Each link stores a destination URL and generates a short code using Moodle’s core \core\shortlink API. When a short link is visited, the shortlink_handler resolves the code and redirects the user to the destination.

There are 3 types of links you can create:

TypeShort code lengthDescription
Short6 charactersStandard short link.
Long12 charactersLonger code, useful if you want more entropy.
Unguessable12 characters + 16-char codeIncludes an additional query parameter (c) with a random base62 string. Bots or users without the full URL cannot guess or crawl the link.
  • Via the web UI — Navigate to the Short Links page and use the “Create short link” form. Enter a destination URL (must be HTTPS), choose a link type, and optionally add tags.
  • Via the API — Use \local_shortlinks\local\api::create(string $destinationurl, type $type, array $tags) programmatically.

Capabilities

  • local/shortlinks:create — Create short links.
  • local/shortlinks:delete — Delete short links.
  • local/shortlinks:edit — Edit short links.