This is the simplest possible PHP-based URL shortener for personal use.
I have been looking for this all over the internet. All solutions were way too big and cumbersome, so I ended up reinventing the wheel.
Convenient features added over time:
- Super super simple:
- The entire actual programming code is inside a single PHP file.
- Links are kept locally in an SQLite Database.
- Links can be configured to first show where they are going. If installed on
https://example.com, then visitinghttps://example.com/someLinkwill first display a page showing the visitor the destination URL, and a "go!" button. "direct" links will still directly be redirected instead. - Visiting the root (
https://example.comin the example above) without being logged in displays a list of all links with thepublicflag. There is also a form to enter the link's name (someLinkin the example above) and hitgo!. - visits are recorded in local CSV log files for further analysis if needed.
- The page is a progressive web app (PWA): you can "save to homescreen" on your mobile to use it like a native app.
- The bookmarklet uses the following GET URL parameters to pre-populate the form for a new link:
namefor the link name (the shortcut)urlfor the target URLdescriptionfor the description
- OpenSearch: When on the page, the user can add it to the browser's search engines. Once added, the user can just enter the link name (e.g.
someLink) and be taken to the link directly.
Just copy the index.php file to your webhosting root directory and open its URL in a browser. Note: your webserver needs full write access to that directory.
The following files will be generated upon first calls:
- A config file named
config.phpwith random passwords and file names - A
*.dbfile for your links sqlite database - A
.htaccessfile for all the redirection and caching magic - A
log-*.csvfile will be generated the first time one of your shortcut links is visited.
You can adjust any of the files to your needs if you know what you are doing.
Pull requests are welcome.