I am tired of TinyURL getting all of the domain “brand share” from my Blogs tweets. So I wanted to come up with my own solution to create short urls using my blogs domain: BrandonsHead.com.
Yes, my domain is longer than “TinyUrl”, and I assume that yours is too – however, those 5 or so extra characters are well worth the brand awareness (especially if you are cross posting to other social media outlets). And thanks to Mod Rewrite and WordPress, pulling this off is relatively simple.
By adding a rewrite rule to WordPress‘ .htaccess file (in the root of your WordPress installation) – you add 1 line of code, and poof you can have a Short URL like http://brandonshead.com/go446
Here is the code that I added to my .htaccess to achieve this:
RewriteRule ^go(.*)? /index.php?p=$1 [R=301,L]
This code is simply saying, any time a user goes to http://mydomain/go123 take the 123 and treat it like a blog post ID, then the rest of WordPress’ rewrite rules will take over.
Here is what my WordPress’ .htaccess file looks like:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
#Short URL Processing
RewriteRule ^go(.*)? /index.php?p=$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Also, we want to make it easy for us and our users to copy and paste this new short url. So I went in and added the following code to my Single.php file (that is part of the theme you are using).
<div class="shorturl">
<label>Short URL</label>
<input type="text" value="http://YOURDOMAIN.com/go<? the_ID(); ?>" onclick="this.select()" />
</div>
Disclaimer: This might or might not make your WordPress installation completely blowup, this is only for the brave of heart. I repeat: This might make your WordPress installation come alive and eat your entire city – so please proceed with caution.


Amen brutha! Fabulous post, and thanks for your work.
“I am tired of TinyURL getting all of the domain “brand share” from my Blogs tweets.” Sorry, meant to quote that. I’m moving too fast here :-/
My pleasure!!
We just developed something similar over here –
http://www.seoegghead.com/software/wordpress-tiny-urls.seo
Pretty similar, but also allows arbitrary URLs to be set, and/or turned off etc. Brandon’s works well too, of course
Jaimie, I couldn’t get your plugin to work in 2.7 and there really isn’t any support info on your site. I installed it, configed it and don’t see the Tiny Url displayed on any page I selected in the config.
Not bad, here is another solution, still using WordPress: Roll your own TinyUrl like redirect engine using a separate install and this theme hack
http://3on.us/your-own-tinyurl
Cheers!
I’ve been using the WordPress plugin Twitter Friendly Links for about a month and it works very well.
http://kovshenin.com/wordpress/plugins/twitter-friendly-links/
Nice find Mr. Hood! It installed beautifully!
wow .. nice trick!
simple but meanfull!
thanks