How to Create Your Own Custom URL Shortener (for Free!)

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:

Let’s dive in! 🚀

Part 1

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 🐒

Part 2

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.

Let’s go!

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 3 years and created 179 shortened links that have been clicked 51.900 times so far:

how much i used yourls

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 3 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:

yourls dashboard

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:

yourls statistics of 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:

steps to register domain in cloudflare

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.

download latest yourls release on github page

Step #6: modify config file

In the User folder, rename the file config-sample.php to config.php.

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.

You can do this through the file manager of your host, or use a FTP manager like Transmit (what I’m using) or FileZilla.

Step #8: finish installation

Go to 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 😄

That’s it!

Your URL shortener is now ready to use 🤓

The end

Now it’s your turn

comment illustration

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.

Avatar of Max van Collenburg
Max van Collenburg

I'm addicted to travel, love a good cappuccino, have two cute cats, and craft actionable content for online business owners that want to grow their business with non-sleazy marketing & automation. More weird facts about me here.

10 thoughts on “How to Create Your Own Custom URL Shortener (for Free!)”

  1. Avatar of Gerjo

    What a great tip, excited to set this up! Thank you.

    • Avatar of Max van Collenburg

      Hey Gerjo! Happy to hear, good luck setting it up! 😄🇳🇱

  2. Avatar of Victoria

    Looks complicated but will give it a go

    • Avatar of Max van Collenburg

      Cool! If you get stuck somewhere, let me know 🙂

  3. Avatar of Richa

    Hey Max,

    Thanks for sharing this amazing tip!

    Wanted to check, if you are aware of any such QR code generator tool as well which can help us create QR code and to track them!

    Cheers,
    Richa

    • Avatar of Max van Collenburg

      Hmm, I don’t know about that. Sorry!

  4. Avatar of Sarah

    I couldn’t get this to work as described as I lack the technical know how. But I was determined to find a way and eventually I managed to install it on a cheap shared hosting account I set up just for the purpose using one of the apps in the c panel. Thank you for the inspiration! I’ve wanted a branded URL shortener for ages but taking on yet another software subscription put me off.

    • Avatar of Max van Collenburg

      Hey Sarah! Happy to hear you got it to work! 💪

      Is there anything I could’ve done differently in this guide to make it easier?

      • Avatar of Sarah

        I tried it the way you described and got really stuck with accessing the SQL database I’d created because I was on a shared hosting service and my host told me I had to create some sort of tunnel 🤷🏻‍♀️😬 I did attempt to follow their instructions but it was beyond me.

        Anyway after a bit more digging I found that if your host offers c panel you can install YOURLS using Softaculous. It’s really easy. Like super easy. And got the job done in under 10 minutes.

        • Avatar of Max van Collenburg

          Yes, databases can be a bit tricky because it’s different at every host.

          But glad you found a way to install it with Softaculous! Maybe others that read this who use cpanel can check if that’s a possibility for them too 😄

Leave a Comment