Remove locale from URL path · Cloudflare Rules docs | Latest TMZ Celebrity News & Gossip | Watch TMZ Live Skip to content
Cloudflare Docs

Remove locale from URL path

Create a redirect rule to redirect visitors from an old URL format with locale information to a new URL format.

This example single redirect for zone example.com will redirect visitors from an old URL format that included the locale (for example, /en-us/<page_name>) to the new format /<page_name>.

When incoming requests match

  • Field: URI Path
  • Operator: matches regex
  • Value: ^/[A-Za-z]{2}-[A-Za-z]{2}/

If you are using the Expression Editor, enter the following expression:
http.request.uri.path matches "^/[A-Za-z]{2}-[A-Za-z]{2}/"

Then

  • Type: Dynamic
  • Expression: regex_replace(http.request.uri.path, "^/[A-Za-z]{2}-[A-Za-z]{2}/(.*)", "/${1}")
  • Status code: 301
  • Preserve query string: Enabled

The function regex_replace() allows you to extract parts of the URL using regular expressions' capture groups. Create capture groups by putting part of the regular expression in parentheses. Then, reference a capture group using ${<num>} in the replacement string, where <num> is the number of the capture group.

For example, the redirect rule would perform the following redirects:

Request URLTarget URLStatus code
example.com/en-us/meet-our-teamexample.com/meet-our-team301
example.com/pt-BR/meet-our-teamexample.com/meet-our-team301
example.com/en-us/calendar?view=monthexample.com/calendar?view=month301
example.com/meet-our-team(unchanged)n/a
example.com/robots.txt(unchanged)n/a

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.