Skip to content

Instantly share code, notes, and snippets.

@comewalk
Created February 22, 2010 15:56
Show Gist options
  • Save comewalk/311186 to your computer and use it in GitHub Desktop.
Save comewalk/311186 to your computer and use it in GitHub Desktop.
write htaccess for my blog
#!/usr/bin/perl
use strict;
use warnings;
use File::Find::Rule ();
use Perl6::Say;
say 'RewriteEngine on';
my $root_dir = "ftp/s14u.info/mt";
my @files = File::Find::Rule->file()
->name(qr/.*\.(html|xml)$/)
->in($root_dir);
for my $from (@files) {
(my $to = $from) =~ s{($root_dir/(archives/)?)(.*)}{http://blog.comewalk.com/$3};
$from =~ s{ftp/s14u.info}{};
if ($to eq 'http://blog.comewalk.com/index.xml') {
$to = 'http://blog.comewalk.com/index.rdf';
}
if ($to eq 'http://blog.comewalk.com/rsd.xml') {
$to = 'http://www.typepad.com/services/rsd/6a00e009972ea488330115715cdc31970b';
}
say "RewriteRule $from $to [R=301,L]";
}
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment