- Download the source code as located within this repository, and upload it to your web server.
- Use
database.sql
to create the redirect
table in a database of choice.
- Rename
config.php.production
to config.php
- Edit
config.php
and enter your database credentials.
- Redirect to your Twitter account when
@
is used as a slug, e.g. http://yourshortener.ext/@
→ http://twitter.com/yourhandle
.
- Redirect to your main website when no slug is entered, e.g.
http://yourshortener.ext/
→ http://yourmaindomain.ext/
.
- Ignores weird trailing characters (
!
, "
, #
, $
, %
, &
, '
, (
, )
, *
, +
, ,
, -
, .
, /
, @
, :
, ;
, <
, =
, >
, [
, \
, ]
, ^
, _
, {
, |
, }
, ~
) 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
.
- 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
http://yourshortener.ext/shorten?url=%@
.
javascript:(function(){var%20q=prompt('URL:');if(q){document.location='http://yourshortener.ext/s/'+encodeURIComponent(q)}}());
javascript:(function(){document.location='http://yourshortener.ext/s/'+encodeURIComponent(location.href)}());