Roll your own Wordpress Tiny URL and Capitalize on your Domain’s Brand.

December 09, 2008 9 Comments Category: Creative, Open Source, Products, Usability

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.

9 Responses

Write a comment
  1. Amen brutha! Fabulous post, and thanks for your work.

    TreoBenny 9 December 2008 at 2:47 pm Permalink
  2. “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 :-/

    TreoBenny 9 December 2008 at 2:54 pm Permalink
  3. My pleasure!!

    brandon.corbin 9 December 2008 at 2:58 pm Permalink
  4. 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 Sirovich 8 January 2009 at 3:08 pm Permalink
  5. 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.

    Jason 15 January 2009 at 10:02 am Permalink
  6. 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!

    Alex Schleber 5 March 2009 at 6:08 pm Permalink
  7. 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/

    Kevin Hood 17 July 2009 at 11:58 pm Permalink
  8. Nice find Mr. Hood! It installed beautifully!

    brandon.corbin 18 July 2009 at 10:27 pm Permalink
  9. wow .. nice trick!

    simple but meanfull!

    thanks :)

    ghprod 10 November 2009 at 1:21 pm Permalink

Write a Comment

Commenter Gravatar