DEV Community

Christopher Chhim
Christopher Chhim

Posted on

Avoiding the Dreaded 404

I am writing this blog to track my progress. I am currently on my second week of back-end development of my bootcamp and I am learning how to work with servers. We are starting to dabble on status codes such as: 200, 400, 401, 400, 500, etc... As I start to learn how to work with servers I want to know how to develop sites without prompting status code 404.

There are several ways to redirect users to a desired page. However, if it is done carelessly it will prompt status code 404, indicating that a bad request has been made. A correct URL would look like the following:

  • /supplements/spore-probiotic-6066

This is correct because it contains the name of the website and the ID.
ID = 6066

Incorrect but acceptable URL would look like the following:

  • /supplements/spore-probiotic

This will still redirect users to the desired URL despite having a missing ID.

  • /supplements/youtheory-spore-probiotic

The aforementioned link includes the brand name and a missing ID but will still redirect users to the desired link. This is because they are known as fallback methods and the database contains built-in methods in case such errors occur. While they not may be completely accurate, it is still within the server's capacity of understanding where the user should be redirected.

This post was inspired from:
Artz, L. (2024, June 10) Designing a website to not have 404s
Retrieved from: [https://pillser.com/engineering/2024-06-10-website-without-404s]

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay