Nano URLs turns any post, page, product or external address into a short link served from your own domain. Nothing is sent anywhere else: the codes, the redirects, the statistics and the API all live inside your WordPress install.
Codes are handed out from a counter rendered in base 62, starting at a single character. The first links on a new site look like example.com/0, example.com/a, example.com/Z. A code only grows to two characters once every one character code is taken, and to three once every two character code is taken. That is 62 links at one character, 3,844 at two, 238,328 at three, and 14.7 million at four.
Codes that would clash with something real are skipped automatically, so a link is never handed out that WordPress cannot serve. That covers existing posts, pages and categories, the WordPress paths such as wp-admin and wp-json, feeds, common shop URLs, and any word you add yourself. Once a code is in use, WordPress is stopped from giving that slug to a post created later, so a link you have already shared cannot be taken away from you.
A short link is answered on plugins_loaded, before the theme is loaded, before the main query runs and before a single block is registered. The whole request is one cached lookup and a redirect header. On sites with a persistent object cache such as Redis or Memcached, a repeat click does not touch the database at all.
Click statistics are written after the response has been handed back to the visitor, using fastcgi_finish_request() where the host supports it, so counting a click costs the visitor nothing.
Works with any public post type, so WooCommerce products, custom post types and anything else are covered without configuration.
A REST namespace at nano-urls/v1 with endpoints to create, list, read, update, delete and expand links, plus daily click counts. Authenticate with an API key issued on the plugin’s API screen, an application password, or a logged in cookie with a nonce. Keys are stored as hashes and act with the permissions of the user they belong to.
There are template tags too, for use in themes and other plugins:
$short = nanourls_shorten( 'https://example.com/page' );
$short = nanourls_get_short_url( $post_id, true );
$target = nanourls_expand( 'a7' );
This plugin makes no external connections of any kind. Click statistics are a running total and a count per day per link. No IP addresses, user agents, referrers or any other personal data are stored.