/CSV-to-IIS-Rewrite-Rules

Primary LanguageC#GNU General Public License v3.0GPL-3.0

CSV to IIS Rewrite Rules

This tiny console application takes a simple CSV file and generates a <rewrite> XML block that can be inserted into a web.config file on an IIS server that supports the IIS Rewrite module.

Usage

CsvToIisRewriteRules.exe -p <csv-file-path> -o <output-directory> [-s] [-a <destination-url>]

Command line parameters

CSV File Path

Specify the path to the CSV file. The file must be in the following format:

http://source-domain.com/source/page-1,https://destination-domain.com/destination/page-1
http://source-domain.com/source/page-2,https://destination-domain.com/destination/page-2

Output directory

The directory into which to write the config file(s) generated by the application.

Separate Config Files (-s)

If -s is specified, the config files will be broken out as follows:

rewriteMaps.config

This file contains the <rewriteMaps/> element, containing all the <rewriteMap/> elements and their individual rewrites.

rules.config

This file contains the <rules/> element, containing all the rules which reference the rewrite maps.

rewrite.config

This file contains references to the rewriteMaps.config and rules.config files generated above.

Note: this file is the default file that is generated and will contain all configuration if the -s parameter is not specified.

Include "Catch-All" Redirect (-a)

If -a is specified, the last rule definition will catch all URLs that weren't matched and send them to the passed-in <destination-url>.