A lightweight, self-hosted URL shortener with click tracking, analytics dashboard, and API.
Stores data in SQLite and JSON files.
No dependencies beyond PHP and SQLite.
- Shorten URLs via API
- Custom or auto-generated short names
- Tracks visits (IP, country, city, referrer, etc.)
- Analytics dashboard (
dashboard.php):- Total clicks, top links, top countries, time series, world map, recent visits
- Terminal dashboard (
dashboard.sh) - API for adding links (
url.php) - Clipboard integration (
urlgen.sh) - Geolocation via ip-api.com
- No external DB required (uses SQLite)
| File | Purpose |
|---|---|
index.php |
Main redirector & visit logger |
url.php |
API for creating short links |
api.php |
Analytics API (JSON) |
dashboard.php |
Web analytics dashboard |
dashboard.sh |
Terminal analytics dashboard |
urlgen.sh |
Bash script to create short links |
.htaccess |
Apache rewrite rules |
urls.json |
Stores short link mappings (auto-gen) |
visits.sqlite |
SQLite DB for analytics (auto-gen) |
- PHP 7.2+ with SQLite enabled
- Apache (or compatible web server with
.htaccesssupport) jqandxclipfor shell scripts (optional)
- Clone or copy files to your server.
- Edit config values in
url.php,index.php,dashboard.php, and scripts:- Set your API key(s), base URL, and dashboard password.
- Ensure PHP can write to the directory (for
urls.jsonandvisits.sqlite). - Configure your web server to use
.htaccessfor pretty URLs.
- Via API:
GET /url.php?key=YOUR_API_KEY&url=https://example.com[&short=customname] - Via Bash script:
./urlgen.sh "https://example.com" [customname]
Support on Liberapay
