I was in the mood for a long post title. Sue me.
My thoughts on URL shortening services are pretty public but that doesn’t mean that I don’t have a need for them. I prefer Bit.ly over any other URL shortening services that I’ve used to-date.
With Tr.im dying I thought that there was always the possibility of Bit.ly going down the same path. It was time to create my own URL shortening service for short URLs pointing to my site using my own domain. I browsed around, found two WordPress plugins that could have been candidates – but ultimately decided to use nothing but vanilla WordPress.
The Short URL plugin makes it very easy to take any URL and make it nice a short, track clicks, etc. I have this installed in case I want to shorten URLs that are not ultimately here on my site. (Though I still plan on using Bit.ly for these links). Short Post URLs is a plugin that seemingly does exactly what I want – which is make a shorter URL automatically for every post here on my site. However, the problem is that by default the plugin does not redirect from the short URL to the long one. This means that my posts would have two URLs. This isn’t what I was looking for and I didn’t want to hack someone else’s plugin.
That is when I saw it, right under my nose. The default link for any post on any WordPress blog is domain.com?p=postID. For instance, the short URL for this post is http://cdevroe.com/?p=2682. If you link to that URL WordPress will automatically forward that request to the full URL. Simple. Beautiful. Exactly what I need.
Occam’s Razor in full effect.
Update: Dean Robinson, maker of the fine mobile Twitter client Hahlo, suggests in the comments adding a simple line to your .htaccess file (if you’re so inclined) to pretty up your URLs. I’ve decided to add this for mine so that now both the original, default WordPress URL of ?p=postID works as well as /p/postID works now. Thanks Dean.
You should check out La Petite URL. I like how it handles the shortened links a lot more:
http://extrafuture.com/projects/la-petite-url/
I will definitely look into this plugin. Too bad it didn’t come up in my searches for multiple combinations for “url short shortener” in the plugins manager.
Which is an awesome, clean, easy route for people with short domains. But if my website happens to be something like “www.iamsobloodyawesomedontyouagree.com”, then regardless of whether I have wordpress or not… I’m going to need a URL shortening service.
And possibly a smack in the face for getting such a ridiculous website URL.
Point taken. Willing to slap.
You can also add one simple line to your htaccess file and clean them up even more, which is what I’ve done on all my WP blogs.
Adding this:
RewriteRule ^([0-9]+)$ ?p=$1 [R=301,L]
Will change: http://cdevroe.com/?p=2682
To simply this: http://cdevroe.com/2682
I’ve seen that some people are also adding /p/ or /s/ before the post id to avoid possible conflicts.
Why didn’t I think of that? Might as well make the URLs clean.
For the record, that short post URLs plugin that I link to does this exactly, except it never ends up redirecting. I’m sure one could take that plugin and do some minimal hacking to get it to work.
For those that don’t add the /p/ it’d actually shorten the URL some. For me, it will stay the same. I think I’ll add this. Thanks Dean!
Of course, there is a downside … it hops twice. Hmm.
I hear that sir right on point. I have my own shortner at http://iqmz.com No one uses it but me and my friends but its mine. It will runn as long as I’m on the nets!
Side note how have you been dude?