If you use WordPress with your own domain and you also promote your blog updates on Twitter, you should seriously consider setting up your own URL shortener so you don’t have to rely on third-party services like bit.ly and tr.im.
2 Big Reasons Why It’s Better To Have Your Own URL Shortener
1. Security concerns – People will not be afraid to click your link since they see your site’s branding in the short URL itself.
2. Reliability – What will happen when the third-party URL shortener service you use goes down or worse completely shuts down?
YOURLS is a PHP script that will let you run your own URL shortening service in your own domain. And with a plugin, you can link it to your WordPress blog so you can automatically generate short URLs for each post and page you publish. But of course, you need to have a short domain name to begin with otherwise you won’t really get short URLs!
You can use YOURLS not just for WordPress but this article will focus on on how to use both. The instructions are split into 3 parts:
Part 1: Installing the YOURLS script to your server
Part 2: Setting up YOURLS for your self-hosted WordPress blog
Part 3: Using YOURLS in a WordPress Post or Page
Part 1: Installing the YOURLS script to your server
1. Download the script at http://yourls.org/.
2. Extract the files and make a copy of the file includes/config-sample.php. Save it as config.php.
3. Open includes/config.php in a text editor. The following are the only settings which need to be changed:
- MySQL database name, username and password
- YOURLS_SITE : the short URL domain without trailing slash – Mine’s http://syaoran.net/u
- $yourls_user_passwords : define users for the YOURLS admin page
Change the other settings only if you understand what they are for.
4. Upload all the files inside the “yourls” folder to the location you defined in YOURLS_SITE. In my case, I uploaded the script in a subfolder to avoid overwriting existing files under my site’s root folder.
5. Go to http://yourdomain.com/admin/install.php or YOURLS_SITE/admin/install.php then click on the Install button.

6. Login using the information you gave in $yourls_user_passwords to access the admin page. You can manage your short URLs here and track click statistics too.
Part 2: Setting up YOURLS for your self-hosted WordPress blog
1. Download the YOURLS WordPress plugin here and upload it to wp_content/plugins. Or better yet, login to your blog’s WordPress admin section and install the plugin automatically by searching for YOURLS in Plugins > Add New.
2. Activate the plugin then go to Settings > YOURLS. Adjust the settings as shown below. Check with your webhost if you’re not sure of the absolute path.
3. Enter your Twitter login details. Change the other settings as you see fit then click Save.
Part 3: Using YOURLS in a WordPress Post or Page
You can go back to your old posts and generate short URLs if you wish to promote them again. You’d see the following widget in the edit page of a published post.

As of now, the automated tweet will not be sent to Twitter for posts scheduled in the future. Anyway, I prefer turning off the automated tweet setting so I can still customize the tweet before it gets sent to Twitter.
I use the same YOURLS install for two blogs. In this journal and in my book blog as well. It’s a fantastic plugin in my opinion.
Related Links:
YOURLS PHP script official site
YOURLS: WordPress To Twitter (a Short URL Plugin) – Author page
YOURLS at the WordPress Plugin repository






Filipino Catholic · Hobby Blogger · 