Showing posts with label web-server. Show all posts
Showing posts with label web-server. Show all posts

Tuesday, November 15, 2011

Script to convert IIRF rules to IIS Rewrite

Use this script in Linux or Cygwin


Example conversion:

#individual page redirects
RedirectRule ^/default.php http://example.com [R=301]

Converts to:

<rule name="RULE_no1"><match url="^/default.php" /><action type="Redirect" redirectType="Permanent" url="http://example.com" /> </rule>

Script:


#!/bin/sh

awk 'BEGIN{OFS=""}/RedirectRule/{ print "<rule name=\"RULE_no",NR,"\"><match url=\"",$2,"\" /><action type=\"Redirect\" redirectType=\"Permanent\" url=\"",$3,"\" /> </rule> " }' $1