Skip to content

Instantly share code, notes, and snippets.

@Olical
Created March 28, 2011 10:12
Show Gist options
  • Save Olical/890237 to your computer and use it in GitHub Desktop.
Save Olical/890237 to your computer and use it in GitHub Desktop.
Turn a table of urls into a list of 301 redirects

Covers the following domain extensions, it's easy to add more.

  • com
  • co.uk
  • net
  • org

Pattern

/(http://www\.|http://)([a-z0-9-]+)\.(com|co\.uk|net|org)([a-z0-9_/\-\.:\?=&]+)\s([a-z_/\-\.:\?=&]+)/gi

Replace

Redirect 301 $4 $5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment