FREE & OPEN SOURCE
PHP Scripts
Free URL Shortener PHP Script with QR Codes
LinkZip: shorten links on your own domain with QR codes and click tracking. Single PHP file, no database.
What it is
LinkZip is a Bitly-style URL shortener that lives in a single PHP file on your own domain. Paste a long link, get a short code plus a scannable QR code, and watch click counts in the admin panel.
Links are stored in a JSON file with proper file locking — no database to set up. Short codes skip look-alike characters (0/O, 1/l/I) so they survive being read out loud. Only http(s) destinations are accepted, and an optional .htaccess snippet (included in the README) gives you pretty URLs like yoursite.com/l/Ab3xYz.
Links are stored in a JSON file with proper file locking — no database to set up. Short codes skip look-alike characters (0/O, 1/l/I) so they survive being read out loud. Only http(s) destinations are accepted, and an optional .htaccess snippet (included in the README) gives you pretty URLs like yoursite.com/l/Ab3xYz.
Server requirements & dependencies
- PHP 8.1 or newer
- No database — links stored in a locked JSON file
- No Composer / npm
- QR rendering uses one client-side JS library from cdnjs (browser-side only; the server calls no external service)
- Any shared hosting plan works
How to install
1. Upload linkzip.php to your web space (e.g. public_html/l/).
2. Open it in your browser once — storage bootstraps and locks itself down.
3. Open linkzip.php?a=admin, generate your admin password hash with the built-in generator, paste it into the CONFIG block.
Optional: add the 3-line .htaccess from the README for pretty short URLs.
2. Open it in your browser once — storage bootstraps and locks itself down.
3. Open linkzip.php?a=admin, generate your admin password hash with the built-in generator, paste it into the CONFIG block.
Optional: add the 3-line .htaccess from the README for pretty short URLs.
The prompt — build it yourself
Paste this into Claude and you'll get this product. This is the actual spec that produced the code above.
Paste this prompt into Claude to build this exact product:
What happened when we ran it: Claude (
Note: the download on this page ships with
Build a complete, production-quality single-file PHP application called LinkZip: a self-hosted URL shortener with QR codes.
Core flow: paste a long URL, get a short link (?c=CODE) plus a scannable QR code; visiting the short link 302-redirects to the destination and increments a click counter.
Hard requirements:
- One PHP file, PHP 8.1+, no database: links live in one JSON file, read-modify-write wrapped in flock (shared lock for reads, exclusive for writes).
- CONFIG constants: DEMO_MODE, CODE_LENGTH, MAX_URL_LENGTH, ADMIN_PASSWORD_HASH, APP_NAME.
- Validation: only http/https destinations, URL length capped, parse_url-based checks. Short codes are generated from an alphabet WITHOUT look-alike characters (no 0/O, 1/l/I) and collision-checked.
- QR: render client-side with the qrcodejs library from cdnjs (the only external asset, browser-side only — the server must not call any external service).
- Admin panel at ?a=admin: session login (password_hash + sleep(1) on failure), KPIs (link count, total clicks, code length), table of links (code, destination, clicks, created date) with per-row delete, CSRF everywhere, first-run hash generator as in the SendZip pattern.
- Demo mode: UI visible, creating links and admin login disabled with a friendly message + top banner.
- Storage folder self-bootstraps with a deny-all .htaccess. Clean dependency-free CSS, dark mode, copy button next to the short link.
Also write a README.md: requirements, 3-step install, a rewrite-rule snippet for pretty URLs (yoursite.com/l/Ab3xYz), security design, and honest limits (JSON scale, abuse note for public shorteners).
What happened when we ran it: Claude (
claude-fable-5) produced the complete file in one pass. Syntax check and the functional tests passed on the first attempt. Your result will differ slightly on every run — that's normal; the spec above pins the behavior, not the exact code.Note: the download on this page ships with
DEMO_MODE = false — no demo restrictions. The prompt is for reproducing (or remixing) the build yourself with your own Claude subscription. Reviews
Used Free URL Shortener PHP Script with QR Codes? A star rating takes two seconds and helps others.
More builds
License: MIT — free for personal and commercial use, no warranty. Software is provided as is; review the code before running it in production (it's short enough to actually read).