Generate HTTP 301 redirect rules from URL lists and filenames
Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
gen301.py
readme.mkd

readme.mkd

gen301

Generate HTTP 301 redirect rules from URL lists and filenames.

From a supported input format of URLs, fuzzy search a directory for filenames that are a sub-string of a URL and output a mapping in one of the supported output formats to stdout.

Input formats

An input format can be one (or any) of:

  • Google Webmaster Tools crawl errors CSV file
  • A newline separated list of URLs

Output formats

  • rack-rewrite 301 static redirect
  • Comma separated list

Examples

$ gen301 -use \
    --gcsv /tmp/Web_crawl_error_sources_www_tlvince_com_20110711T030411Z.csv" \
    --plain /tmp/disqus-urls.csv \
    --dirs ~/proj/blog/journal/entry \
    --output rack | sort > /tmp/301s

... which generated these redirects in production.