I want to configure the routing for my Angular app on Azure static web app so that the following configuration works as expected
My staticwebapp.config.json
{
"routes": [
{
"route": "/old-route/page/",
"redirect": "/new-route/page/",
"statusCode": 301
},
{
"route": "/old-route/page/:filepath",
"redirect": "/new-route/page/:filepath",
"statusCode": 301
},
{
"route": "/old-route/page/{id}",
"redirect": "/new-route/page/{id}",
"statusCode": 301
},
{
"route": "/old-route/page/:path*.aspx",
"redirect": "/new-route/page/:path",
"statusCode": 301
}
],
"navigationFallback": {
"rewrite": "/index.html",
"exclude": [
"*.{css,scss,png,gif,ico,jpg,svg}"
]
}
}
The first one works as expected.
The second and third should be redirected to "/new-route/page/:filepath" with the filepath or ID. but nothing of them works as expected. The fourth one should be redirected to "/new-route/page/:path" without extension. but all are not working as expected except the first one.
is my configuration correct and is there any way to overcome this issue?
I agree with MikeOne, Thanks for your Insights
As Per this MSDoc Link, This wildcard is useful when you want to capture a variety of routes under a common pattern
I have tried with my below
staticwebapp.config.json
and deployedResult:
In the context of a route like
"/profile*"
, the asterisk (*
) is a wildcard character that matches zero or more characters. This is often used in route patterns to capture multiple possibilities.In the example
"/profile*"
, it would match any route that starts with "/profile", followed by zero or more characters. For instance, it would match "/profile", "/profile/settings", "/profile/123", and so on.