---
title: "Regex based redirects for Static Web Apps"
url: https://daily.dev/posts/regex-based-redirects-for-static-web-apps-ucw1lqdb9
source_url: https://www.damirscorner.com/blog/posts/20260612-RegexBasedRedirectsForStaticWebApps.html
type: article
source: "Damir's Corner"
published: 2026-06-12T07:50:17.204Z
updated: 2026-06-12T07:50:43.994Z
tags: ["typescript", "azure-functions"]
reading_time: 3
upvotes: 3
comments: 1
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Regex based redirects for Static Web Apps

**[Damir's Corner](https://daily.dev/sources/damirscorner)** · 3 min read · 3 upvotes · 1 comments

## Summary

When migrating a blog to Azure Static Web Apps, the built-in route configuration lacks support for regex-based redirects with back-references. A workaround uses an Azure Function as a navigation fallback: unresolved paths are routed to the function via `navigationFallback` in `staticwebapp.config.json`, the original URL is read from the `x-ms-original-url` header, and JavaScript's `String.replace()` with regex capturing groups handles the redirect logic. Redirect rules are stored in a JSON file and matched at runtime, returning 301 redirects on match or a custom 404 page otherwise. A sample TypeScript project with GitHub Actions deployment workflow is provided.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.damirscorner.com/blog/posts/20260612-RegexBasedRedirectsForStaticWebApps.html>

## Similar posts on daily.dev

- [Apex domain redirect for Azure Static Web Apps](https://daily.dev/posts/apex-domain-redirect-for-azure-static-web-apps-q75vf5ssp) · Damir's Corner · 0 upvotes · 0 comments

---

Tags: [#typescript](https://daily.dev/tags/typescript), [#azure-functions](https://daily.dev/tags/azure-functions)

[View this post on daily.dev](https://daily.dev/posts/regex-based-redirects-for-static-web-apps-ucw1lqdb9)
