DEV Community

manish srivastava
manish srivastava

Posted on

5

404 Error as Url Shortner without db

Hey,
Recently I created a small script with just few lines of code as Url Shortner.

First how it works then where I am using it.

  1. How it works

This is my url : https://getus.live

Now anything you type like
https://getus.live/yourname

Will redirect it to default 404 page as nothing is 'yourname' on server / linked to server.

I modified 404 default page to catch anything after my domain name. In this case /yourname is catched by 404 page and array with key ( yourname) will be redirected to "value" of the key. This value is long url.

Workflow:
In index page I asked the user to give the long url and key.
This will write a array with key and value. The key here is /yourname and value will be longurl.

To see in action visit
https://getus.live
Try yourself.

  1. Where I am using it

(1) Url Shortner
(2) Navigation System
(3) Referal System catching values etc
(4) Bash UI to run commands.

Bye!!!

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more