URL Rewrite for Angular

We’re using Cloudflare to load balance an Azure Storage Account with Static Site enabled. I need to implement a URL Rewrite Transform to rewrite all angular-routes to / or /index.html

We do this today with Verizon CDN with the following regex:

I figure I’m not the first one doing rewrites for angular routes here so I thought I’d ask.



Thank you for asking.

I am afraid you cannot use regular expressions in Transform Rules if not at least on a Business plan.

Source article:

From what I understand, it looks for dot files inside a directory (if so), and then what?

Thanks for the info, we are an enterprise customer. I’m able to select regex when creating the transform.

The supplied regex basically looks for anything lacking a ‘.’ aka .jpg / .svg / .js
and rewrites it to index.html


Maybe you might have to re-write your regex to RE2 as I think it doesn’t support ? (guessing / looking for) :thinking:

Otherwise, combine “OR” operator to get it correct (if path contains .jpg and something OR path contains svg and something …)… might have to try it out first and reply back here :smiley:

Yeah I’ve been looking for an online RE2 parser to play around with. Thanks for the info.

1 Like

As far as Cloudflare uses RE2 and RE2 is lacking of lookaheads (Syntax · google/re2 Wiki · GitHub), should be like:


  • https://www.domain.com/url/
  • https://www.domain.com/some-url/
  • https://www.domain.com/abc-def-ghi/ab/something/

Don’t match:

  • https://www.domain.com/url/assets/image.svg
  • https://www.domain.com/assets/style.css
  • https://www.domain.com/dir/something/script.js
    → not anything that goes like “dot” something

But with exclusion as don’t.match even https://www.domain.com/index.html, as we might end up in a loop and as far as we rewrite to this.

Rewrite them to /index.html.

Interesting, I’ll give this a shot, thanks for the example!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.