Skip to content

Instantly share code, notes, and snippets.

@seemly
Created September 9, 2025 14:52
Show Gist options
  • Select an option

  • Save seemly/9f232b116e38283132ba22534c9ffac2 to your computer and use it in GitHub Desktop.

Select an option

Save seemly/9f232b116e38283132ba22534c9ffac2 to your computer and use it in GitHub Desktop.
This is a formula snippet for Google Sheets to prepare the From column in WP Engine regex URL redirects.
/*==========================
1.) Google Sheets spreadsheet should have a sheet named 'source' and a another called 'target'.
2.) 'source' sheet should contain raw/unprocessed export of 'From' and 'To' columns. Therefore, column selectors may need updating.
3.) Copy and paste each of the formulas below as appropriate into your 'target' sheet.
==========================*/
/*. From column */
=ARRAYFORMULA(
IF(LEN(source!A2:A),
IF(REGEXMATCH(source!A2:A, "\.[a-zA-Z0-9]+$"),
"^" & REGEXEXTRACT(source!A2:A, "https?://[^/]+(/.*)"),
"^" & REGEXREPLACE(REGEXEXTRACT(source!A2:A, "https?://[^/]+(/.*)"), "/$", "") & "/?$"
),
)
)
/*. To column */
=ARRAYFORMULA(IF(LEN(source!B2:B), source!B2:B, ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment