In this article, we’ll show how to use the Apache HTTP server’s mod_rewrite feature to set up your own URL shortener.
How to build a URL shortener with Apache | Opensource.com
This approach uses the RewrtieMap feature of mod_rewrite and a virtual host configuration to serve shortened URLs. I wonder if nginx can do something similar?