As I convert more sites over from WordPress, it would be very handy to have a bulk 301 redirect system. I’m finding myself doing this manually far too often.
WordPress blogs are usually /blog-post-slug and the Webflow is always /post/blog-post-slug
Is there an easy way to redirect all those?
Am I missing something here?
Thanks for reaching out about the bulk redirects. At the moment there is not an option to bulk import the redirects, see here on the Wishlist: Bulk addition of redirects | Webflow Wishlist
Their is a good chance this will be added in the near future, but in the meantime, I usually use google sheets and keyboard maestro (or similar program for Windows) to add the redirects by automating those keystrokes and actions necessary to enter the redirects from the google sheet.
@cyberdave - Do you mind explaining more about your redirect process using keyboard maestro?
I’m in the same situation with nearly 24,000 redirects I need to include - I have the Google Sheet with the Old to New URLs listed out, I just need to get them into Webflow!
Yeah, a bit of a hack on Janne’s import script here and Laura’s script update here, and you can make an export script.
Here’s how to use it;
Login to webflow, go to site settings, to the publishing tab where you see the redirects list
Open Chrome dev tools CTRL+SHIFT+I
Go to the console
Paste this script and press enter
var hostingContainer = document.getElementsByClassName('redirects')[0];
var hostingController = angular.element(hostingContainer);
var scope = hostingController.scope();
var csv = `"Source","Dest"\r\n`;
scope.redirects.forEach(function (rule) {
csv += `"${rule.src}","${rule.target}"\r\n`;
});
console.log(csv);
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
hiddenElement.target = '_blank';
hiddenElement.download = 'redirects.csv';
hiddenElement.click();
That last bit should automatically create and download a CSV file, you can save it where you like. If it doesn’t work, you’ll see the CSV in the console as well and can copy paste.
I haven’t tested this on a large set of redirects, hopefully it will get all of them.
Anyone who uses this, please let me know if it worked for you, and how many redirects you exported. I’m very curious to know how smoothly it works on a large list, if at all.
Unfortunately the export script from @memetican and others no longer works - it looks like the WF team have changed their front-end framework.
Here’s an updated version. It’s not terribly robust as it assumes WF won’t change things again, but it works for now!
To run, you first need to select the text “301 redirects” on the site settings page (the new framework uses unintelligible class names so it’s hard to identify the table of redirects).
var tableRows = document.getElementsByTagName('tr');
var csv = `"Source","Dest"\r\n`;
for (let i = 0; i < tableRows.length; i++) {
let spans = tableRows[i].getElementsByTagName('span');
if (spans.length >= 2) { // Check if we have at least two spans (source and destination)
let source = spans[0].innerText;
let destination = spans[1].innerText;
csv += `"${source}","${destination}"\r\n`;
}
}
console.log(csv);
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
hiddenElement.target = '_blank';
hiddenElement.download = 'redirects.csv';
hiddenElement.click();