# Change example.com to the correct host
wget -r -nd --delete-after -w 0.5 'http://www.example.com/' 2>&1 | 
  grep -B3 text/html |
  grep -B2 '200 OK' | egrep 'https?://' | 
  cut -d' ' -f3- | 
  sort | uniq | 
  ruby -ane 'puts "rewrite ^#{$_.strip.sub(%r{^https?://[^/]+/}, "/")}$ / permanent;"'