php-url-shortener

Simple PHP URL shortener, as used on mths.be

  • 所有者: mathiasbynens/php-url-shortener
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Simple PHP URL shortener

Requires PHP ≥ 5.4.0 or higher.

Installation

  1. Download the source code as located within this repository, and upload it to your web server.
  2. Use 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.)
  3. Edit config.php and enter your database credentials.
  4. For additional security through obscurity™, consider renaming shorten.php to a secret file name of your choosing and tweaking the .htaccess file (line 3) accordingly.

Features

  • Redirect to Twitter when given a numerical slug, e.g. http://mths.be/8065633451249664http://twitter.com/mathias/status/8065633451249664.
  • Redirect to your Twitter account when @ is used as a slug, e.g. http://mths.be/@http://twitter.com/mathias.
  • Redirect to your Google Plus account when + is used as a slug, e.g. http://mths.be/+https://plus.google.com/u/0/116553353277057965424/posts.
  • Redirect to your main website when no slug is entered, e.g. http://mths.be/http://mathiasbynens.be/.
  • Redirect to a specific page on your main website when an unknown slug (not in the database) is used, e.g. http://mths.be/demo/jquery-sizehttp://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. http://mths.be/aaa) → same effect as visiting http://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 SettingsServicesURL ShorteningCustom… and enter http://yourshortener.ext/shorten?url=%@.

Favelets / Bookmarklets

Prompt

javascript:(function(){const%20q=prompt('URL:');if(q){location='https://yourshortener.ext/shorten?url='+encodeURIComponent(q)}}());

Shorten this URL

javascript:(function(){location='https://yourshortener.ext/shorten?url='+encodeURIComponent(location.href)}());

License

This script is available under the MIT license.

Author

Contributors

主要指標

概覽
名稱與所有者mathiasbynens/php-url-shortener
主編程語言PHP
編程語言PHP (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2010-11-29 20:43:15
推送於2020-06-23 08:03:34
最后一次提交2017-08-19 13:45:52
發布數0
用户参与
星數333
關注者數24
派生數94
提交數40
已啟用問題?
問題數8
打開的問題數0
拉請求數3
打開的拉請求數1
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?