Reclaim Your Twitter Links

14 Apr 2009, Posted by admin in Featured,Whitehat, 19 Comments

Reclaim Your Twitter Links

On the one hand, I love the Tweetmeme plugin for WordPress, I think it does an amazing job of letting your visitors easily retweet your blogpost. It looks really nice, it’s really easy to install and it even tracks the number of retweets you get. In short, it’s simple and effective. On the other hand though, I hate it. I really, really hate it. When people hit the retweet button, it doesn’t retweet me – it retweets @techmeme. I can’t style the button, I have to use theirs. And I really, really hate the fact that my links get retweeted with a URL shortener. I’ve spoken before about how much I hate URL shorteners – they dilute your brand and can, for some of them, prevent link juice from reaching your site.

The RT @tweetmeme is pretty unneccessary. Tweetmeme are taking your content and attaching their brand name to it instead. This makes me sad.

The styling of the button annoys me because it doesn’t always fit into your theme. Sometimes you want your page to look how you want it to look, rather than have buttons tacked onto it, looking all green and out-of-place.

And the URL shortener is bad. If Google treats in the same way as it treats TinyURL, then any links that get passed around because of @tweetmeme won’t give you any link juice. This is pretty much a crime.

But Here’s How To Fix All That

You can create your own URL shortener, exclusive to your blog. Easily, if you’re running WordPress at least. You’ll be able to have URLs that look like Check out the Twitter icon at the top of this post , see where that links to if you hit it.

For WordPress, create a folder within the root of your domain. Name it “go”, or something equally short. Then make a .htaccess file and include the following code:

RewriteEngine On
RewriteRule ([0-9]+) /index.php?p=$1 [R=301,L]
RewriteRule (.*) / [R=301,L]

The easiest way to make that a .htaccess file is to post that code into notepad, save it as a .txt and then upload it to the “go” folder on your server. Then rename it to .htaccess. Windows sometimes has a bit of a tantrum if you try to change it on your machine locally.

This code basically says “Whenever the URL /go/ is accessed, and the file specified is numbered, add that to index.php?p=. If it’s not a number, go to the homepage.

Put that .htaccess file in your new /go folder.

To test that your 301s are working, open your WordPress admin panel, go to Manage > Posts and then hover over one of your posts. You should see in the small link-to box a post number.

An earlier examples of linkbait post, for example, is number 190. Try going to (or whichever number of you found). It should redirect you to the relevant post (like here). That redirect is a 301, by the way, so all the link juice will be passed to the right page when people link to that URL. Hat tip to for revealing this simple but awesome tip.

Next, you’ll want to create and style your own Twitter button so that, when it retweets, it retweets your Twitter name instead of @techmeme. The good news is, you can use any image or text to retweet, it’s just a link to Twitter.

To do this, go into your theme editor in WordPress, open up the single.php (or whichever file you’re using for your single post theme), find the button that you want to be your Twitter button, and add an a href code around it to make it a link to Twitter. Here’s the code for the link:

<a href=” @yourname <?php the_title(); ?> – <?php echo get_option(‘home’); ?>/go/<?php echo $post->ID ?>”></a>

The @yourname you obviously change to whatever your Twitter username is. The <?php the_title(); ?> is simply the title of the blog post. The <?php echo get_option(‘home’); ?> is the root domain of your blog, followed by the /go/ which is your new, personalised 301ing URL shortener. The <?php echo $post->ID?> is the number of your post, so it’ll complete the URL shortened link. That will give a result, for my previous TinyURL page, as a link that looks like @SharkSEO TinyURL Doesn’t Pass Value –

And there you have it, you get to keep your brand name instead of passing out Techmeme’s. If people want to follow you from retweets, it’s easier for them. More importantly, instead of risking losing your well deserved link authority, you’ll get it all going straight to your blog. Enjoy, and don’t forget to retweet this post 😉

(Flickr image from jenteach123)

Promote Post

Enjoyed this post?


April 14, 2009 3:55 pm


I love this trick and have already implemented it. One problem I see is that you may want to use “php echo get_bloginfo (‘url’)” instead.

April 14, 2009 8:52 pm


Very nice… I cannot wait to get some time with my test site and see if I can make it work.

Question: I’m anticipating a bit of a problem if there’s a blog with multiple authors… some of which are on Twitter, some of which are not. Any thoughts on how one would conquer that?


April 15, 2009 2:58 pm


@James, this tweak is intended to make tweeting easier for your visitors. Your blog authors don’t need to be on Twitter – I’m not.

April 16, 2009 7:52 pm

the State of Flux

This is a great tip! I implemented it straight away.

So you are aware, your example href statement is missing a > immediately before the

April 16, 2009 9:00 pm


Cheers State of Flux, good spot – fixed

April 17, 2009 9:14 am


Great trick indeed! It’s rather annoying to promote another website with your own content…

May 8, 2009 12:39 pm

How To Create Your Own TweetMeme Button – PimpMyWordPress

[…] a big thanks goes to for finding a great solution. Now you can create your own retweets button with just one line of […]

May 13, 2009 12:04 am


I liked this so much I endorsed it to a client. However, now I’m trying to set it up and hit a problem.

“open up the single.php (or whichever file you’re using for your single post theme), find the button that you want to be your Twitter button, and add an a href code around it to make it a link to Twitter.”

I’m not seeing the code that renders the button. What version of the TM Button did you install? Please let me know asap.

May 13, 2009 4:07 pm


Hey man, thanks for a quick reply. I was overthinking this.

So there is no need to even install the tweetmeme plugin?

May 13, 2009 4:55 pm


Cool. I’m an SEO from Miami and I’m a (new) fan of your blog.

October 24, 2009 4:35 am

Carter Cole

if you use google apps then you can use the link shortening app mine is here it tracks clicks but you dont have to have anything but a domain name

October 26, 2009 2:45 pm


I’ve been setting up my WordPress blogs recently with /%post_id%/%postname%/ permalink structure. This allows me to post and it directs to the post without the above changes.
However, it does not redirect to the full post_id/postname url. Am I creating duplicate content? Am I hurting myself like this? Or, does this create a similar effect as above?

November 4, 2009 3:07 pm

Shark SEO

Hi Fox, it’s good thinking but unfortunately you’re right – you’re creating duplicate content there. As the URLs and are both accessible, without one redirecting to the other – any links that go to one won’t count for the other. You can use that method if you found a way to include canonical tags (there might be a plugin, but I’ve got no idea if one exists – I’ve not checked). Otherwise, you could use the method above to help – it’s quite easy if you’re comfortable with a bit of hacking things around, just make sure you backup stuff in case it all goes awry – and good luck 🙂

February 12, 2010 5:06 pm

Hack the Sociable Plugin to Use Your Own URL-Shortener

[…] you haven’t set up your own link-shortener yet, follow the easy instructions here, first. To get the shortest URL possible, we suggest you use a one-letter directory name for your […]

January 8, 2014 12:29 pm

Marketing Lynx

Nice tip. will probably make short URL’s myself in the future.

Posting your comment...