How To Create Your Own Tiny URL

If you have ever clicked my “Tweet This Post!” icon at the bottom of the post, you’ll see that it will take you to Twitter so you can tell all your followers about the great post you’ve just read. Because of the 140 character limit, URLs that are longer than 30 characters are shorten with an URL shortening service like TinyURL or Bit.ly. If you look at the URL I use, you’ll see that it still has johnchow.com in it. I do this to maintain and reinforce my brand. Here’s how to create your own tiny URL for your WordPress blog.

Shortening The Default WordPress URL

We begin by shortening the WordPress URL structure. By default, WordPress names its URL as yourblog.com/?p=xxxx, with the xxxx being the post number. The default URL isn’t very Google friendly and most bloggers will turn on the SEO friendly URL instead. However, the default URL will still work even if you’ve turn on SEO friendly URL. The URL will simply forward to the SEO one.

Because it’s a lot shorter, the default WordPress URL makes a great starting point to create our own custom short URL. The first thing I did was remove the ?p= so the URL becomes johnchow.com/xxxx. You do this by adding the following code to your htaccess file.

RewriteCond %{REQUEST_URI} ^/([0-9]+)$
RewriteRule .* https://www.johnchow.com/?p=%1 [R=301,L]

Change jonchow.com to your domain and you should be good to go. I highly recommend you back up your htaccess file before editing it.

Create The Tweet This Post Link

The following code will create the Tweet This Post link you see at the bottom of my blog articles.

<a rel=”nofollow” href=”http://twitter.com/home/?status=Reading @JohnChow – <?php the_title(); ?> https://johnchow.com/<?php the_ID(); ?>”><img src=”https://www.johnchow.com/images/tweet-this.png” alt=”Tweet This” /> <strong>Tweet This Post!</strong></a>

Insert the above code (change to your domain and twitter name and upload your own bird image and link to that) into your WordPress single.php file at the point where you want the Tweet This link to show up. In my case, I have it appear at the end of the post. If you click the Tweet This Post link, it will send you to Twitter and the following tweet would be insert into your What are you doing? box.

Reading @JohnChow – How To Create Your Own Tiny URL https://johnchow.com/9894

Doing it this way allows me to bypass the use of an URL shortening service. JohnChow.com only has one more letter than TinyURL.com so this isn’t a big deal. What is a big deal is the URL has my blog domain name in it and reinforces my brand. The other advantage is I don’t have to worry about TinyURL or bit.ly going down and messing the URL up. You can save yourself a few letters by using www instead of http:// as Twitter.com will auto link the URL. However, Twitter clients like TweetDeck will not link the URL if it’s missing the http:// so I recommend you stick with that and not brother with the www.

You won’t have to worry about readers seeing the shorten URL after they get to your blog because WordPress will auto forward them to the SEO friendly URL. I added a ref=nofollow tag to ensure that no Google juice is passed to the short URL.

If you like this post, please click the Tweet This Post link and tell all your followers about it. 🙂