Simple PHP URL shortener, as used on mths.be
Simple PHP URL shortener, as used on mths.be
Requires PHP ≥ 5.4.0 or higher.
database.sql to create the redirect table in a database of choice. (Do not delete the INSERT statement on line 10 as it is needed to initialize the database.)config.php and enter your database credentials.shorten.php to a secret file name of your choosing and tweaking the .htaccess file (line 3) accordingly.http://mths.be/8065633451249664 → http://twitter.com/mathias/status/8065633451249664.@ is used as a slug, e.g. http://mths.be/@ → http://twitter.com/mathias.+ is used as a slug, e.g. http://mths.be/+ → https://plus.google.com/u/0/116553353277057965424/posts.http://mths.be/ → http://mathiasbynens.be/.http://mths.be/demo/jquery-size → http://mathiasbynens.be/demo/jquery-size.!, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, @, :, ;, ``, [, \, ], ^, _, {, |, }, ~) in slugs — useful when your short URL is run through a crappy link parser, e.g. http://mths.be/aaa) → same effect as visiting http://mths.be/aaa.[a-z] characters.http://yourshortener.ext/shorten?url=%@.javascript:(function(){const%20q=prompt('URL:');if(q){location='https://yourshortener.ext/shorten?url='+encodeURIComponent(q)}}());javascript:(function(){location='https://yourshortener.ext/shorten?url='+encodeURIComponent(location.href)}());This script is available under the MIT license.
No open issues yet, or sync has not completed.