Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Short URL

Security covered Under active development 46 sites

This module provides a URL shortening service for Drupal that can generate custom or random short URLs. It automatically handles redirects, tracks visits with statistics and charts, and can generate QR codes for your short links. A REST API is also available for programmatic access to expand URLs and retrieve statistics.

A URL shortener for Drupal built on node entities, with QR code generation, visit tracking, statistics, and a REST API.

Features

  • Short URL content type with three slug modes: custom vanity slugs, random base36 slugs, or sequential auto-increment slugs
  • Automatic redirects via the Redirect module — redirects are created and synchronized when short URLs are saved or deleted
  • Per-short-URL redirect status (301, 302 or 307), starting from the site default
  • CSV import from a CSV file or a YOURLS export, creating or updating short URLs, from the admin form or Drush
  • QR code generation (PNG and SVG) using endroid/qr-code, accessible via /api/shorturl/qr/{slug} endpoints
  • Visit tracking via a lightweight HTTP middleware that records visits without bootstrapping Drupal on cached requests
  • Statistics dashboard on each short URL node with traffic charts, referrer analysis, and country-of-origin mapping
  • REST API for programmatic URL expansion and statistics retrieval
  • Views integration with a pre-configured admin listing
  • Granular permissions for slug modes, statistics viewing, API access, and administration
  • Browser cache control with an optional no-store header on redirects for accurate visit counting
  • Multi-language support — per-translation redirects with language-neutral fallbacks
  • Optional country detection via the Smart IP module
  • Multi-domain support via the separate Domain Short URL module (requires the Domain module)

Requirements

Installation

composer require drupal/shorturl
drush en shorturl

Configuration

Navigate to Administration > Configuration > Short URL settings (/admin/config/shorturl/settings) to configure:

  • Base36 slug length (4–12 characters)
  • Default redirect status code (301, 302, or 307) for new short URLs; each short URL keeps its own
  • Destination type (external only, or both internal and external)
  • QR code format (PNG or SVG)
  • Administration theme for short URL pages
  • Visit tracking (enable/disable)
  • Browser cache control (no-store header on redirects)
  • Built-in statistics (store visits in the database, or rely on external analytics only)
  • Visit retention (delete visits older than a number of days on cron)

Slug modes

Each short URL uses one of three slug modes, controlled per-node and restricted by permissions:

Mode Permission Example Custom Use custom short URL slugs promo Base36 Use base36 short URL slugs k9m2x7 Auto-increment Use auto-increment short URL slugs 42

REST API

All API endpoints require the Access Short URL API permission. The statistics endpoint also requires View any short URL statistics, or View short URL statistics on a short URL the user can view, and the database statistics endpoint requires View any short URL statistics. The expand and QR code endpoints answer 404 for a short URL the user cannot view.

Endpoint Description GET /api/shorturl/expand/{slug} Expand a slug to its destination URL GET /api/shorturl/stats/{nid} Visit statistics for a short URL GET /api/shorturl/db-stats Aggregate database statistics

QR codes

QR code images are available at:

  • /api/shorturl/qr/{slug} — default format (configured in settings)
  • /api/shorturl/qr/{slug}/png — PNG format
  • /api/shorturl/qr/{slug}/svg — SVG format
  • /{slug}.qr — the short URL's own QR code address

The PNG and SVG images open in the browser, where they can be copied or saved.

Documentation and demo

Previous module

This project namespace was previously used by an unrelated Drupal 6/7 module developed by the Phase2 Technology company. The original code is still available in the 6.x-1.x branch. The original project was not covered by the Security Advisory Policy.

Ask your assistant about Short URL

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
8
Tracked since
Apr 2026
Latest release
2 weeks ago
Releases (12 mo)
8 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
2.0.0-beta2 Pre-release 10–11 Sep 25, 2026
2.0.0-beta1 Pre-release 10–11 Jun 9, 2026
2.0.0-alpha4 Pre-release 10–11 Apr 13, 2026
2.0.0-alpha3 Pre-release 10–11 Apr 13, 2026
6.x-1.0 Stable Apr 13, 2026
2.0.0-alpha2 Pre-release 10–11 Apr 13, 2026
2.x-dev Dev 10–11 Apr 13, 2026
2.0.0-alpha1 Pre-release 10–11 Apr 13, 2026