Introduction
Shlink is a self-hosted URL shortening service that gives you full ownership of your short links and their analytics. Built with PHP on the Mezzio framework, it provides a REST API for creating and managing short URLs, detailed visit statistics with geolocation, and QR code generation. A separate web client offers a management dashboard for non-technical users.
What Shlink Does
- Creates short URLs with custom slugs, tags, and expiration dates
- Tracks visits with geolocation, referrer, browser, and device data
- Generates QR codes for any short URL automatically
- Supports multiple custom domains from a single instance
- Provides a REST API for programmatic URL management
Self-Hosting & Configuration
- Deploy with Docker using a single container and environment variables
- Connect to PostgreSQL, MySQL, or MariaDB for production storage
- Configure GeoLite2 database for visitor geolocation tracking
- Set up the Shlink Web Client for a browser-based management UI
- Use environment variables to control URL validation and redirect behavior
Key Features
- Multi-domain support with per-domain short URL namespaces
- Real-time visit webhooks for integration with external analytics
- URL validation to prevent shortening broken or malicious links
- Bot detection and filtering in visit statistics
- Import short URLs from Bitly, YOURLS, or CSV files
Architecture Overview
Shlink is a PHP application built on the Mezzio microframework with Doctrine ORM for database access. It runs as a self-contained Swoole or RoadRunner server inside Docker, requiring no external web server. Visit tracking data is stored in the relational database with optional GeoLite2 lookups for IP geolocation. The REST API follows a consistent JSON schema with API key authentication.
Comparison with Similar Tools
- YOURLS — PHP-based but older architecture; fewer analytics features
- Kutt — Node.js alternative; smaller community and fewer integrations
- Bitly — SaaS-only; not self-hostable
- Polr — abandoned project; no longer actively maintained
FAQ
Q: Does Shlink require a web server like Nginx or Apache? A: No. The Docker image runs a built-in Swoole or RoadRunner server. You only need a reverse proxy for TLS termination.
Q: Can I use multiple custom domains? A: Yes. Configure additional domains in the admin UI or via the API. Each domain can have its own set of short URLs.
Q: How does visit tracking work? A: Each redirect logs the visitor's IP, user agent, referrer, and timestamp. Shlink resolves IPs to locations using the GeoLite2 database.
Q: Can I migrate from Bitly to Shlink? A: Yes. Shlink includes a built-in importer that reads Bitly export files and recreates your short URLs with their original slugs.