Use Your Own Wordpress Blog and Domain Name to Shrink URLs
August 22nd, 2009
Twitterheads know that a good URL shortening service can go a long way. There’s a ton of them out there (most notably): tinyurl, bit.ly, and ur.ly. You’ve no doubt seen shortened URLs thousands of times while normally browsing the web. When you submit a link to Twitter, if the link is longer than 26 characters, Twitter will automatically shorten the URL using bit.ly. For a variety of reasons, it makes damn good sense to use your own domain to shorten your URLs. For Wordpress users it will take less than five minutes to build your own URL shortening service.
Why Should You Care?
1. Branding - When you write a blog post that gets popular, it will be very advantageous to have your own URL floating around the web instead of bit.ly’s.
2. Tracking - The URL shortening service that I’m about to show you tracks the amount of clicks you get on your link.
3. Permanency - Since you control the meta data, there’s no risk that the shortening service will shut down and all of your links will point to 404 page not found errors.
4. It’s free - This process won’t cost you anything–including your time (okay, maybe five minutes tops).
5. Update: Checking RTs: On Twitter you can easily search for any retweets by punching your own domain name into Twitter search.
Let’s Get to It
For Wordpress users, you can reuse your existing database. Remember that two step process for installing Wordpress? This process is just as simple. The shortening service will add two tables to your database. Start by downloading YOURLS from Google Code. Go ahead and grab either version 1.3 RC1 or 1.2.1. I installed 1.2.1.
Configure the Settings
Inside the /includes directory there is a file called config-sample.php. Just like when you installed Wordpress for the first time, you just need to change a few settings and rename the file config.php (just like Wordpress). I found it quickest just to log into my server and download the wp-config.php file I use for Wordpress, because the settings are practically the same. You only need to customize the first four of the six options. The image below explains which settings need to match Wordpress.
The Last Couple Settings
There are two more settings you need to customize in config.php. You need to add your own domain name to the config file. I recommend using a one character sub-directory to keep your server tidy (keep Wordpress and YOURLS config files separate). In the image below you can see that I use y. I think it’s easy to remember k-potty. : )

I recommend keeping your URL shortening service private so your blog doesn’t become a spammer’s dream. You will need to assign a private key string that will be unique to the cookies created by YOURLS. The quickest way to grab one is to jump over to YOURLS site and they will provide a random key: http://yourls.org/cookiekey.php. I’ve deleted part of my key in the screen shot below. Lastly, to keep things simple I recommend using the same username and password that you use for Wordpress. Obviously, you’re free to use whatever username and password you’d like.

Second to last step
If you’re using a sub-directory, you need to edit the .htaccess file to use your sub-directory. Make sure you bookend your sub-directory with slashes: RewriteBase /sub-directory/.
Last Step
Lastly, create the sub-directory using your FTP program of choice and upload the files. Head over to http://yourdomain.com/sub-directory/admin/install.php and install the shortening service! It should look something like this:


Using Your Own Service!
You can navigate to http://yourdomain.com/sub-directory/admin to use your new service. You can also jump over to http://yourdomain.com/sub-directory/tools.php and you’ll find two very handy bookmarklets for customizing your links.


Closing
If you have any questions or run into any trouble, leave me your questions in the comments and I’ll lend a hand. Happy shortening! Thanks to Kevin Purdy for his original write up. Thanks for your time.
Leave a Reply