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.
Link types
There are 3 types of links you can create:
| Type | Short code length | Description |
|---|---|---|
| Short | 6 characters | Standard short link. |
| Long | 12 characters | Longer code, useful if you want more entropy. |
| Unguessable | 12 characters + 16-char code | Includes an additional query parameter (c) with a random base62 string. Bots or users without the full URL cannot guess or crawl the link. |
Creating links
- 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.