How to Use Drupal to Create Your Own URL Shortener

URL shortener Using Drupal image

Problem: You’re over at (or any of the other URL shortening services) and the shortcut you want to use isn’t available.

Solution: Use Drupal!

You might be thinking “Why would I use Drupal for such a simple service? That’s a lot to maintain for something so ‘trivial’.” Let’s think about two reasons:

  1. This will be your service. You can create an unlimited number of shortcuts without ever competing with anyone else. Have you ever shared a google doc? Here’s what the link looks like – That’s very memorable. Now try: See the point?
  2. Drupal 10 will eventually have automatic updates. Since this site is a stand-alone “service”, enabling this feature will basically let the site take care of itself. In the meantime, a simple composer command once in a while will take care of it! (

Using Drupal to Create Your Own URL Shortening Service

I set this exercise up at and its something I actually use a lot!

Here’s the frontpage for a site visitor.

When I’m logged in the front page is the Redirect module. This makes accessing this section incredibly easy.

Here are the steps you’ll take:

  1. Secure the shortest domain you can find. Of course it doesn’t need to have “url” in the name, just anything you like as long as it’s the fewest number of letters possible.
  2. Create a Drupal site at the domain.
  3. Add the Redirect module (
  4. Create a page for people who “stumble” onto the site.
  5. Make the Redirect module your frontpage.

Steps 1 through 3 are straightforward and covered in many other tutorials on this site (

Step 4: Create a page for people who “stumble” onto the site.

  1. Head over to Content -> Add Content -> Basic Page.
  2. Create the content of the page to suit your liking (see the above image for mine or visit
  3. Head over to Configuration -> System -> Basic Site Settings and enter /node/1 in the Default 403 (access denied) page field.
  4. Click Save.

Step 5: Make the Redirect module your front page.

This is even more simple.

  1. Head over to Configuration -> System -> Basic Site Settings and enter /admin/config/search/redirect into the Default front page field.
  2. Click Save.

Now, when you’re logged in, the Redirect module is your front page!


The only thing missing from our URL Shortener service is statistics. There is a module for that, however it’s not ready for Drupal 10 at the time of this writing. There IS a patch if you’re feeling daring! (

The hardest part of this entire exercise is finding a short domain! If you use any kind of URL shortening service, having your own that’s easy to use and maintain is a really a great way to provide that service for yourself.

For a more detailed look at creating this service for yourself, we have a mini-course ready to go:


  • Rod Martin

    Rod holds two masters degrees and has been training people how to do "things" for over 25 years. Originally from Australia, he grew up in Canada and now resides just outside Cincinnati, Ohio. He has worked in both the non-profit and for-profit worlds, in small companies and large corporations. His extensive open source experience includes WordPress, Joomla and Drupal and he really knows how to help you get the most out of the system you chose. Rod plays ice hockey a couple of times a week and rides his Goldwing motorcycle pretty much everywhere he can.

    View all posts
0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x