URL shortener with custom domain for free in WordPress

URL shortener with custom domain for free in WordPress

Lately, some of our clients have been considering using a URL shortener with their custom domain. This is because links created with e.g. bit.ly are not easy to remember and the statistics are visible to nearly anybody. The price of a premium version that has pretty links and a custom (sub)domain is hundreds of dollars per month. And the competition isn’t much cheaper.

So, why shouldn’t you create your own URL shortener? The only thing you need is WordPress, an easy-to-use template, one plugin and a little bit of security!

How does the URL shortener on WordPress work?

Our shortener uses domain merimeweb.cz (in English measureweb.cz). If you click this link https://merimeweb.cz/mertetaky, you will be redirected to https://marketingmakers.net/webova-analytika/?utm_source=facebook.com&utm_medium=post&utm_campaign=mertaky2504. Subsequently, Google Analytics shows us how many clicks are generated from this campaign. As well as WordPress, the plugin Redirection has easy analytics too.

This is generally all we want from a URL shortener. We want a custom domain, a pretty URL and basic analytics data.

How do I create my first shortlink?

  1. Login to WordPress.
  2. In the left menu, choose Tools –> Redirect –> Add new.
  3. We recommend creating a link with this setting. Your custom domain will be used automatically, in our case https://merimeweb.cz.
    • You should see your new shortlink URL – in our case /mertetaky.
    • In the right corner, there’s the option to select Regex – but don’t use it unless you can use regular expressions.
    • Query parameters – click Ignore and pass parameter to the target – e.g. Facebook pass its fbclid parameter that is used for user pairing.
    • Target URL – paste the full URL of a target here. I recommend including UTM parameters that you can build e.g. through UTM Builder.
  4. Now you can add and test your first shortlink.

How do I create a similar URL shortener?

1. Register your new domain or use your subdomain

Your URL shortener needs a domain, preferably shorter than your own domain. Book any. You can even use a subdomain of your own web e.g. short.example.com.

You need a webhosting for this domain. The easiest way is to install your shortener to your current hosting. All hoststings can make aliases (more domains on one hosting) – and usually one alias is free.

2. Install WordPress

On most popular hostings, you can complete a one-click WordPress install. If not, the full WordPress installation is pretty easy.

3. Install the plugin Redirection

On most popular hostings, you can complete a one-click WordPress install. If not, the full WordPress installation is pretty easy.

For the purposes of this article, we’ve chosen the plugin Redirection because it’s free to use and we’ve used it on our websites for a long time without any problems. Despite the fact that it’s free, I recommend donating a small amount to the developers to help with future shortener development work.

In the plugin settings, there is no need for any setup. However, you can e.g. set up statistics persistence, http/https redirection options or browser cache (default 1 hour).

Also, remove all other WordPress plugins.

4. Install the Redirect theme

Install our Redirect theme, which is unique because it contains nothing. There are only 3 files that consist of:

  • rules that force auto-update of WordPress and all plugins – so you don’t need to do this manually
  • what should happen if a user pastes a URL that isn’t included in the shortener, e.g. merimeweb.cz/something.

The text that follows this example can be changed in Settings –> General.

And that is all – the theme is absolutely empty apart from these two things. Similarly, remove all other inactive themes. You will certainly see e.g. Twenty nineteen, Twenty seventeen, etc. An inactive theme can be a security violation as well.

5. Remove all pages and posts.

This is so we don’t get any comment spam or let any page violate other websites on the same webhosting.

This is it! Now you can create shortlinks!

The total time for all the steps mentioned above is 1–3 hours, depending on the time it takes for SSL certificate activation, DNS setup (this may be up to 24 hours) and server-side settings (e.g. htaccess file problems) – this may be needed because of Redirection plugin activity.

Provide us with feedback, report bugs, subscribe for updates

This is version 1 of this tool. We wanted to solve a problem with expensive tools and get a freedome in settings, domain number, etc. This isn’t the only tool for WordPress – you’ll find many plugins in Google, mostly ones that you have to pay for and that are too complex for this easy task. This article is an extremely easy example of how to achieve good results.

Originally, we developed this tool for some of our clients. We’ve monitored it and, though we’ve so far found no problems with it, we’re pretty sure that some bugs will emerge at some point. If this happens, please report them to shortener@marketingmakers.net.

The template cannot update itself yet. If we publish an update, we’ll send details to subscribers of this list (we will not use your contact information for any other purposes).

For ideas and questions, feel free to use our comments.