Top Nav

Generate Rewrite Rules From CSV File

Here’s a simple Perl script that can be used to convert a CSV file of redirects into Apache rewrite rules:

The script assumes that you have 2 column – the source URL and the destination URL. You might invoke the script like this:

Sometimes the CSV file will be DOS formatted to I’ll do:

There are may ways that this script could be expanded or improved but it’s a good starting point for the typical case.