A weird mistake one of my clients is making: If an invalid/inaccessible URL...


A weird mistake one of my clients is making:

If an invalid/inaccessible URL is requested, they redirect to /404.

Don’t do this. If an invalid URL is requested, the URL shouldn’t change.

Solution: Use a wildcard route to display a 404 page on all invalid routes.
Why this matters:

1. If the URL changes to /404 after I request it, it's confusing. That's not the URL I requested.

2. It's semantically incorrect. A 404 page shouldn't have a dedicated URL.

3. If I want to report a URL that is 404'ing, I can't see the URL in the bar anymore.

View original on X