One week ago, one of the many URL shortening service provider, tr.im, announced that they are shutting down. Services like bit.ly, shorturl and tinyurl have become important since Twitter came about. Luckily for WordPress users, it provides you with a WordPress Short URL for every posts and pages.
Still, the closing of tr.im does bring about the question of how long before others shut down too? What will happen to all the short urls already created? Well, simply said, they will no longer work to bring visitors to the desired destination.
The Problem To Those Who Use Short URLs Extensively
Many people, especially Internet Marketers make use of short urls for various reasons. Internet Marketers are the ones who will probably be effected the most with the shutting down of Short URL sites. When the service goes down, so does all the short links.
Do you have a large number of tiny urls generated for you? Have you posted them in various websites to bring traffic to your domain? Guess what.. You will have to generate new tiny urls. You will also have to edit all your postings, if you can, and put in the new short urls you’ve created. Otherwise, you’ll certainly lose all the traffic you’ve enjoyed in the past from the short urls you’ve created.
Make Short URLs Using WordPress On Your Own Domain
If you use WordPress as your website or blogging platform, you’re in luck. You can configure WordPress to generate Short URLs automatically. All that’s needed is a few lines of code which you can copy and paste into your themes and htaccess.
The following short tutorial will configure WordPress to generate short urls using the post and page id – yourdomain.com/b/post-id for blog posts and yourdomain.com/p/page-id for pages.
Let’s get directly to the codes. First, copy these into your .htaccess file
{code type=xml} # BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^b/([0-9]+)$ /index.php?p=$1 [QSA]
RewriteRule ^p/([0-9]+)$ /index.php?page_id=$1 [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
{/code}
Next, you will need to edit one your theme file – header.php and insert the following lines
{code type=php}
<?php if(is_single()) { ?>
<link rel=”shortlink” href=”<?php bloginfo(‘home’) ?>/b/<?php the_ID(); ?>” />
<?php }?>
<?php if(is_page()) { ?>
<link rel=”shortlink” href=”<?php bloginfo(‘home’) ?>/p/<?php the_ID(); ?>” />
<?php }?>
{/code}
The code above will insert the shortlink meta tag into your webpages. This meta tag will be used by services like Twitter to determine the short url to use fro your web page. Twitter will now use the short url indicated by this meta tag instead of generating a new url for your page.
The place to insert the code above is within your themes <head></head> space. There should be a WordPress Loop in there. Just insert the Php code above somewhere in between the loop.
That’s all there is to it. After you’ve added the above codes into place, your wordpress installation will generating your short urls for you automatically. You no longer need any third party URL Shortening Services. Your short urls will be available as long as your site is up.
The Shortcomings Of A WordPress Generated Short URLs
Not everything is fine and dandy with hosting your own Short URLs with WordPress. As with anything in life, generating your own short url with WordPress do have its downside. Lets take a look at a few of them which I can think of right now.
- Lack of statistics. If you are of the type that likes to have statistics on your Short Links, you will probably not like this. I don’t think there will be any statistics available for this type of Short URL implementation.
- Cannot insert special code. Most third party URL Shortening Services allows you to insert special codes or notes to the generated short urls. This is not possible with this method. This method does not allow any input from you part. Short URL is generated using post and page id respectively.
- You can only shorten links for posts and pages hosted in the WordPress environment. If you want to shorten pages external to WordPress, you can’t with this method.
- Should you somehow have to rebuild your WordPress installation from an XML export of your current site, you will lose your old shortened links. WordPress generates new ids for your imported posts and pages.
- Of course, your domain name should be relatively short for this to be effective. If your domain name is like thisisasampleofaverylongdomainname.com, then it’s best to just use the many third party URL Shortening Services.
WordPress Short URL Plugins For The Non Coders
If meddling with your .htaccess and WordPress header theme files is not your cup of tea, then you can go the WordPress plugin way of doing the same thing. Yes, there are quite a few plugins out there on the net for WordPress that will enable you to shorten your urls.
Among the few which I’ve tested are:
- Short URL Plugin
- Short URL Generator
- Short Post URLS
- Custom URL Shorter
- Short Link
- RevCanonical
- ShortURL
- Get ShortLink
Yes, I’ve installed and tested the plugins above. However, in the end, I decided to go without any of them. Why? Not because the plugins are not good or anything. I just wanted to minimize the number of plugins I have installed on my WordPress installation. Since the coding is not too difficult, I decided to run without plugins.
Another URL Shortening Alternative
If you want to host your own URL Shortener and require more functions than what WordPress is capable of providing, then the following are a couple of alternatives you have.
- Install YOURLS on your hosting server. YOURLS is a server based web application. You can basically just install it into your domain hosting account and run it there.
- Build your very own URL Shortening application. I found an interesting basic guide on this on the net. If you feel like jumping into Php codes and SQL queries, head on over to Sean-O’s URL Shortener Tutorial.
URL Shortening Services are here to stay. Even if Twitter currently favors bit.ly to shorten URLs submitted to them, other Shortening Service Sites will probably continue to function as usual.
Want to know how important a shortening service is? Well, users of tr.im have managed to make the owners of tr.im to go back on their decision to shut down tr.im.
Do you use URL Shortening Services? Have you thought about what will happen to your short links if the provider goes under?
Using the htaccess method described above, the WordPress Short URL for this post is https://maaxii.com/b/1187 (Not anymore, see update)
That’s certainly way shorter than the original url: https://maaxii.com/wordpress/wordpress-short-url-tutorial/
UPDATE
You can now use WordPress’ default shortlink. Don’t have to do anything, it’s available by default. This post’s default shortlink is https://maaxii.com/?p=1187