An URL shortener is really awesome for online businesses if you want to share content online.
But regular URL shorteners have some problems, and can come with monthly fees.
So in this guide, I’ll show you how you can create your own custom URL shortener for free in less than an hour 🙂
The only thing you need is hosting and a short domain.
Here’s what we’ll cover:
- Part #1: about URL shorteners
- Part #2: creating your URL shortener
Let’s dive in! 🚀
About URL Shorteners
Before we’re creating one.
Let’s first talk about what it is.
And why it’s so handy for your online business.
What is a URL shortener?
A URL shortener is a service that takes a long URL and turns it into a shorter URL.
Example: www.maxvancollenburg.com/really-long-url/ → maxvan.co/a8s
The URL shortener “remembers” the full address of the URL you give it and when other users go to the shortened URL, they are automatically redirected to the full address.
This is useful because shorter URLs are easier to remember and share.
URL shorteners also track how many people click on the shortened URL, which can be useful information for your online business 🤓
What to use a URL shortener for?
You can use shortened URL’s for plenty of handy things;
- Use shortened URL in a tweet
- Use shortened URL in a YouTube video
- Use shortened URL in a Facebook post
- Use shortened URL in an email
- Use shortened URL in a text message
- Use shortened URL in a (guest) blog post
- Use shortened URL in a forum post
- Use shortened URL in a chat message
- Use shortened URL in printed advertising
I’m personally using it most on my YouTube Channel, and when answering questions in Facebook Groups.
The problem with free URL shorteners
There are plenty of URL shortening services that let you shorten URLs for free.
But the biggest problem is that those free services use their own domain, which often have a bad reputation because scammers & spammers use them to hide the destination of that link.
So the solution would be to use your own custom domain with these services.
And while that’s possible with most URL shorten services, they almost always ask a premium for it.
Why create your own custom URL shortener?
Creating your own custom URL shortener has a couple of benefits;
- Use your own domain name.
- Privacy-friendly since only you can access the data.
- Cheaper because you only pay for hosting & domain.
- No limits: create & track as many links as your heart desires.
- More control as you can do whatever you want.
But there’s maybe also some downsides to consider;
- You have to install the application yourself.
- It’s smart to update the application sometimes.
For me it was a no-brainer, and I actually enjoyed setting it up 🐒
Create your own URL Shortener
You don’t have to be a programmer.
The hardest part is to come up with a good domain name.
For our custom URL shortener, we’re going to YOURLS.
(YOURLS stands for Your Own URL Shortener)
I’ve been using YOURLS for the last 4 years and created 179 shortened links that have been clicked 51.900 times so far:
I love YOURLS for a couple of reasons:
- It’s completely free: no monthly fees or licenses 🥳
- It’s easy to use: no reason to make url shortening complex (which many online tools do justify the price).
- Low maintenance: I only had to update it once in the last 4 years.
- Detailed statistics: you can see traffic statistics for each short URL.
- It has an API: bit techy, but allows you to create short URLs in other applications.
This is what the dashboard looks like:
Personally, I think it looks a bit outdated, but I’m too lazy to customize something only I see 🤷♂️
What’s also nice, is that you can see detailed statistics of each short URL:
Let’s build it, shall we? 💪
Step #1: choose your short domain
You could use your main domain, but it’s probably smart to come up with something shorter.
For example, the URL of this website is
maxvancollenburg.com and I’m using
maxvan.co as my URL shortener.
But you can also get a bit more creative than me 🐒
Here are some tips:
- Make it easy to remember: handy if you print it or if people have to type it over from a video.
- Look if you can shorten your existing domain name somehow.
- Use a related word to your business.
- Be creative with domain extensions: you don’t have to use .com necessarily.
- Avoid something completely random like j43hf.com since it will look spammy.
- Avoid dashes. They don’t look nice and it’s more likely for people to make typo’s.
Go crazy! 🚀
Step #2: register your domain
I recommend registering with Cloudflare as they register domains with no price markup—you pay what they pay for registration.
Besides being cheap, they are one of the fastest DNS providers in the world, which means people get connected to your domain a few milliseconds faster compared to most other providers.
To register a new domain, create an account & go to Register Domains:
If it’s available, you’ll see a Purchase button 🙂
It’s also okay to register your domain elsewhere if you’ve already registered your domains somewhere else. It doesn’t matter so much.
Step #3: get hosting
You can use any hosting you like because it’s such a lightweight application. It takes up 5 MB storage, and just one database to store shortened URLs in.
I’m using Cloudways because I already have a server there for my website, so it doesn’t cost me anything extra to add an extra website.
Step #4: create database
To store the shortened URLs that you create, and to track how often links have been clicked, we’re going to need a database.
Creating those is usually pretty easy, but it depends on which hosting provider you’re using.
Step #5: download YOURLS
Download the YOURLS source code by going over to Github to grab the latest release.
Step #6: modify config file
User folder, rename the file
Then, open the file in a plain text editor and find the code below 👇
/** MySQL database username */ define( 'YOURLS_DB_USER', 'your db user name' ); /** MySQL database password */ define( 'YOURLS_DB_PASS', 'your db password' );
In that file, replace what I marked in red with your database username and database password.
After you’ve done that. Hit save 😄💾
Step #7: upload files
Now it’s time to upload all the YOURLS files.
Step #8: finish installation
https://yourshortdomain.com/admin/ and follow the steps to complete the installation 🙂
When setting your username & password, use something incredibly strong so it doesn’t get hacked.
Optional: redirect homepage
Since your URL shortener is probably not for public use, you don’t have any use for the homepage.
That’s why I recommend to upload a simple file to redirect the homepage of the URL shortener to the homepage of your main website.
Create a new file called
index.php and add the code below to it.
<?php header("Location: https://www.yourwebsite.com"); die(); ?>
(don’t forget to replace the domain)
Then, upload it to the main folder where you also uploaded the other YOURLS files.
The homepage should redirect now to your website 😄
Your URL shortener is now ready to use 🤓
Now it’s your turn
I hope you enjoyed this guide about URL shorteners.
Now I would like to hear from you:
Did this guide help you to create your own custom URL shortener?
Or do you think it’s too much effort?
Whatever it is, let me know in the comments below.