- Download the source code as located within this repository, and upload it to your web server.
- Use
database.sql
to create theredirect
table in a database of choice. - Edit
config.php
and enter your database credentials.
- Redirect to Twitter when given a numerical slug, e.g.
https://mths.be/8065633451249664
→https://twitter.com/mathias/status/8065633451249664
. - Redirect to your Twitter account when
@
is used as a slug, e.g.https://mths.be/@
→https://twitter.com/mathias
. - Redirect to your Google Plus account when
+
is used as a slug, e.g.https://mths.be/+
→https://plus.google.com/u/0/116553353277057965424/posts
. - Redirect to your main website when no slug is entered, e.g.
https://mths.be/
→https://mathiasbynens.be/
. - Redirect to a specific page on your main website when an unknown slug (not in the database) is used, e.g.
https://mths.be/demo/jquery-size
→https://mathiasbynens.be/demo/jquery-size
. - Ignores weird trailing characters (
!
,"
,#
,$
,%
,&
,'
,(
,)
,*
,+
,,
,-
,.
,/
,@
,:
,;
,<
,=
,>
,[
,\
,]
,^
,_
,{
,|
,}
,~
) in slugs — useful when your short URL is run through a crappy link parser, e.g.https://mths.be/aaa)
→ same effect as visitinghttps://mths.be/aaa
. - Generates short, easy-to-type URLs using only
[a-z]
characters. - Doesn’t create multiple short URLs when you try to shorten the same URL. In this case, the script will simply return the existing short URL for that long URL.
- DRY, minimal code.
- Correct, semantic use of the available HTTP status codes.
- Can be used with Twitter for iPhone. Just go to Settings › Services › URL Shortening › Custom… and enter
https://yourshortener.ext/shorten?url=%@
.
javascript:(function(){var%20q=prompt('URL:');if(q){document.location='https://yourshortener.ext/shorten?url='+encodeURIComponent(q)}}());
javascript:(function(){document.location='https://yourshortener.ext/shorten?url='+encodeURIComponent(location.href)}());
This plugin is dual licensed under the MIT and GPL licenses. Take your pick.