---
title: "Comment by Favourite Jome on \"Dynamic routes recipes from Next.js App Router\" | Hashnode"
description: "Thanks for sharing! I have a question, what if you want a specific dynamic route, like on /a and /b and nothing else? So if /c is entered you&#39;d go to the 40"
url: "https://hashnode.com/posts/dynamic-routes-nextjs-app-router/654c9783e070fcc3b5804af3/comment/655ecc4b356b1a848aa3df0f"
---

[Discussion](https://hashnode.com/posts/dynamic-routes-nextjs-app-router/654c9783e070fcc3b5804af3)

Comment [Dynamic routes recipes from Next.js App Router](https://hashnode.com/posts/dynamic-routes-nextjs-app-router/654c9783e070fcc3b5804af3)

[Favourite Jome](https://hashnode.com/@Favourite)

[Nov 23, 2023](https://hashnode.com/posts/dynamic-routes-nextjs-app-router/654c9783e070fcc3b5804af3/comment/655ecc4b356b1a848aa3df0f)

Thanks for sharing!

I have a question, what if you want a specific dynamic route, like on /a and /b and nothing else?

So if /c is entered you'd go to the 404 page.

I wanted to implement this but couldn't figure it a while back.

[Tapas Adhikary](https://hashnode.com/@atapas)

[Nov 23, 2023](https://hashnode.com/posts/dynamic-routes-nextjs-app-router/654c9783e070fcc3b5804af3/comment/655ecc4b356b1a848aa3df0f#reply-655ed18c356b1a848aa3df7e)

Hey [Favourit](https://hashnode.com/@Favourite), How are you, man? It's a great question. I can think of two ways(but I haven't found any other direct way yet!)

-   If the routes are specific, then they may not be dynamic. Specific routes can be static and deal with them as the static routes.
    
-   The problem with the first approach is, what if the route segments are way big in number? And What if you do not know about the segments beforehand? In this case, control it at the segment generation level, not the route level. Routing goes by pattern. If the pattern is the same, and for that, you want to opt out of a few segments, take them out in our logic where you generate the segment... Let's say, your dynamic route pattern is /blog/${slug}, in this you want to take /blog/what-a-good-day and /blog/i-am-great but I want to ignore /blog/not-so-great, ignore it USE NEXT.JS MIDDLEWARE. With that you can include named parameters: /about/:path matches /about/a and /about/b but not /about/a/c
    

You can read about them from the middleware doc, and I will also teach these concepts in my nextjs playlist on YouTube :)

[Favourite Jome](https://hashnode.com/@Favourite)

[Nov 23, 2023](https://hashnode.com/posts/dynamic-routes-nextjs-app-router/654c9783e070fcc3b5804af3/comment/655ecc4b356b1a848aa3df0f#reply-655eff9784fcf8866e4ba116)

I'm doing great [Tapas Adhikary](https://hashnode.com/@atapas)

Yeah, like you mentioned, though I could specify the routes segment by what if they are a large number.

I expected the \[[nextjs.org/docs/app/building-your-application/rou…](https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes#generating-static-params)\](Generating Static Params) to work.

I'd read more on middleware, thanks. Also, looking forward to the YouTube playlist

[Tapas Adhikary](https://hashnode.com/@atapas)

[Nov 23, 2023](https://hashnode.com/posts/dynamic-routes-nextjs-app-router/654c9783e070fcc3b5804af3/comment/655ecc4b356b1a848aa3df0f#reply-655f138084fcf8866e4ba42a)

[Favourite Jome](https://hashnode.com/@Favourite) very cool.. please let me know when you have additional findings on this. Take care.
