Created
September 4, 2025 13:41
-
-
Save seemly/08f9b1cfcc94a1188833b84654f6c1f4 to your computer and use it in GitHub Desktop.
WP Engine - Bulk Export Rewrite Rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*================ | |
| In the absence of support to Bulk Export all rewrite rules from WP Engine, I wrote the following snippet. | |
| 1.) Navigate to the Rewrite Rules in the Web Rules section of your WP Engine dashboard. | |
| 2.) Copy and paste the below code into your web dev console. | |
| 3.) Save the CSV to your machine. | |
| ================*/ | |
| (() => { | |
| const rows = document.querySelectorAll("tr.MuiTableRow-root"); | |
| const data = []; | |
| rows.forEach(row => { | |
| const cells = row.querySelectorAll("td"); | |
| if (cells.length < 7) return; | |
| const grab = el => { | |
| if (!el) return ""; | |
| const span = el.querySelector("span"); | |
| return span?.getAttribute("aria-label")?.trim() || span?.innerText?.trim() || el.innerText.trim() || ""; | |
| }; | |
| const type = cells[1]?.innerText.trim() || ""; | |
| const source = grab(cells[2]); | |
| const target = grab(cells[3]); | |
| const behaviour = cells[4]?.innerText.trim() || ""; | |
| const comment = cells[5]?.innerText.trim() || ""; | |
| const andCond = cells[6]?.innerText.trim() || ""; | |
| if (!source && !target) return; | |
| data.push([type, source, target, behaviour, comment, andCond]); | |
| }); | |
| const header = ["Type","Source","Target","Behaviour","Comment","AndCondition"]; | |
| const csv = [header, ...data] | |
| .map(r => r.map(v => `"${v.replace(/"/g, '""')}"`).join(",")) | |
| .join("\n"); | |
| const blob = new Blob([csv], {type: "text/csv"}); | |
| const url = URL.createObjectURL(blob); | |
| const a = Object.assign(document.createElement("a"), { href: url, download: "rewrite-rules.csv" }); | |
| document.body.appendChild(a); | |
| a.click(); | |
| URL.revokeObjectURL(url); | |
| a.remove(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment