- Create dedicated domain on an Apache server that supports .htaccess
- ssh to root directory there
- Use random.org to create 200 random strings. (Five characters long, with digits, uppercase letters and lowercase letters).
- Save to short-strings.txt
- echo "RewriteRules On" > .htaccess
- cat short-strings.txt | awk '{print "RewriteRule ^"$1"$ TO [R,L]"}' >> .htaccess
- rm short-strings.txt
- When you want to shorten a URL, edit .htaccess. Replace any TO with the long URL.
My shortener is at s.gonze.com. I already own gonze.com, so adding a subdomain is easy. I use a dedicated subdomain because I don't want the big .htaccess file to slow down other pages.
These are the first lines in .htaccess at s.gonze.com:
# enable rewrite rules
RewriteEngine On
# if somebody requests s.gonze.com/jzPqF, send them to tinyurl.com/
RewriteRule ^jzPqF$ http://tinyurl.com/ [R,L]
# the next short URL I will create is s.gonze.com/esW7j
RewriteRule ^esW7j$ TO [R,L]
The key thing is that the short URLs are not serial numbers, like integers from 1-10,000. This would be easy for anybody to spider, and that would be a privacy loss. Using random strings makes them a lot harder to guess, which more or less defeats spiders.