I recently decided to abandon YOURLS as my shortlink solution, opting instead to handle short URLs entirely within WordPress. This choice is not a reflection on YOURLS–it’s still a great product–but rather was borne from my use case for shortlinks; I concluded that, since I only used them in conjunction with WordPress, an external shortlink service was excessive.
While WordPress has provided a native shortlinks feature since the 3.0 release, it uses query strings rather than pretty permalinks. This means that the shortlink for this post would be http://ethitter.com/?p=6360. It’s not the prettiest URL, nor will many systems cache that request; as a result, each shortlink that’s followed would load all of WordPress just to perform a redirect to the post’s full URL. Unsatisfied with Core’s handling but also unwilling to retain YOURLS, I wrote a small WordPress plugin to address my needs.
ETH Simple Shortlinks converts query-based shortlinks to versions that use WordPress’s rewrites system. When active, http://ethitter.com/?p=6360 becomes http://ethitter.com/p/6360/, though the former URL will still resolve as expected.
The plugin overrides the shortlink output WordPress generates, ensuring that the new format is used wherever a short URL is expected. For convenience, the shortlink is also exposed in content lists in the WordPress admin.
By default, the plugin supports posts and pages that are either published or scheduled. Filters allow other post types and statuses to be included.
The plugin is available from the WordPress.org repository: https://wordpress.org/plugins/eth-simple-shortlinks/. Development is on GitHub: https://github.com/ethitter/eth-simple-shortlinks.