...

/

The redirectTo Route

The redirectTo Route

Let's explore how we can use 'redirectTo' route for handling the edge cases of URLs.

What is the redirectTo route?

So, we know about the wildcard route handler and how it runs when a URL is entered into the address bar that doesn’t match one of our defined routes, but what if we don’t want the user to go to the page not found section? For example, what if the user enters http://localhost:4200/client instead of http://localhost:4200/clients? It seems a bit unfair to send them to a page not found when they were so close to the correct route. Well, this is where redirectTo routes come in.


A redirectTo route is a route that we set up as a way of capturing these edge case URLs that the user may put in.


Example of redirectTo route

For example, here is a redirectTo path for the /client URL:

📝 Note: Press the RUN button to ...