Skip to content

Instantly share code, notes, and snippets.

@stevemeisner
Last active December 23, 2015 09:28
Show Gist options
  • Select an option

  • Save stevemeisner/6614304 to your computer and use it in GitHub Desktop.

Select an option

Save stevemeisner/6614304 to your computer and use it in GitHub Desktop.
How to efficiently do 301's for Typewriter
INSERT INTO `redirects` (`match`, `redirect_to`, `account_id`, `created_at`, `updated_at`)
VALUES
('/old_page.php', '/new/page', 40, NOW(), NOW()),
('/old_page_two.php', '/new/page/two', 40, NOW(), NOW()),
('/old_page_three.php', '/new/page-two', 40, NOW(), NOW());
1. Start with going to http://www.xml-sitemaps.com/ and generating the sitemap.
2. Choose the option to "Download Sitemap in Text Format". It will give you "urllist.txt" with each result on one line.
Open this file with BB Edit and use the following find and replace:
Find: "\r"
Replace with: "', '/new/page', 40, NOW(), NOW()),\r\t('"
Both without the wrapping quote marks, obviously.
You can then replace the the lines in the SQL file above starting with line 3 with your newly formatted 301 list, and once you've filled out the "redirect_to" field for all URLs, you can run it all at once, and be done with it.
@stevemeisner
Copy link
Author

on Line 6, replace the \r with \n and it will work in sublime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment