Routing confusion..... Question

Ok, so If I have one route setup like this:
route1
and then I have another route setup like this:
route2

does the second route not work because the route with the variables thinks it should do that first? I'm just trying to iron some issues out. You work on an issue for so long, its best to seek clarity sometimes

Thanks
Baub

Hi @baub

I'm certainly no expert on this but yes, I would say the second isn't working because of the first.

Maybe try switching the order in the .htaccess file?

Or do something in your database so Race-Windows and Flats is in there so that you can then redirect to the page you want when those two get vars match that?

Edit: You're on ASP aren't you? I don't think IIS has .htaccess files so you'll need to check the MS equivalent of this. Does Wappler let you drag the routes to change the order? I've never tried to do that.

yeah its in the web.config file for IIS

I'll have to rethink how I have the URLs setup

I would consider adding to the start of your route so something like:

/product/:broadtype/:manufacturer

Then that will only be used when the url begins with /product (or whatever would work for you).

can I have multiple routes to the same page?

Can I setup a
/race-windows/:broadtype/:model
/flats/:broadtype/:model

But yet have them both go to accessory-details.aspx page etc?

I've never done that before but I can't see why that wouldn't work. But I think the result would be the same for both. They would both point to:

/accessory-details.aspx?broadtype=x&model=x

so there wouldn't be much point.

You would be better off making the first part dynamic, too:

/:type/:broadtype/:model

Then they would both go to the same page but you can differentiate between them.

Yeah that's what I did originally, but have a lot of other routes that I am dealing with as each of the application types have to go to a different type of page as the product details are different. I'll work on it a bit more and see where I get.

1 Like

I don't know about aspx, but in NodeJS (ExpressJS) and similar platforms, routing is prioritized by order. If the 1st route matches the criteria, the 2nd route is ignored, so it's your task to order the route definitions accordingly

1 Like

ChatGPT says this:

Yes, rules in web.config files (particularly rewrite rules in the <rewrite> section) are processed in the order they are listed.

Maybe I'll give that a spin, put all of the urls with variables at the end of the list. I will be fine tuning this today and will reply back with where I get...

Happy Monday!

1 Like