Hi, I am looking for a scalable solution to replace all the underscores with hyphens. Is it possible to rewrite the expressions below into one single in/out rule?
<rewrite><rules><rule name="5" stopProcessing="true"><match url="(.*)-(.*)-(.*)-(.*)-(.*)-(.*)" ignoreCase="false" /><action type="Rewrite" url="{R:1}_{R:2}_{R:3}_{R:4}_{R:5}_{R:6}" /><conditions><add input="{REQUEST_FILENAME}" pattern="^.+\.(axd|asmx|ashx|js|css|jpg|png|gif|pdf)$" negate="true" /></conditions></rule><rule name="4" stopProcessing="true"><match url="(.*)-(.*)-(.*)-(.*)-(.*)" ignoreCase="false" /><action type="Rewrite" url="{R:1}_{R:2}_{R:3}_{R:4}_{R:5}" /><conditions><add input="{REQUEST_FILENAME}" pattern="^.+\.(axd|asmx|ashx|js|css|jpg|png|gif|pdf)$" negate="true" /></conditions></rule><rule name="3" stopProcessing="true"><match url="(.*)-(.*)-(.*)-(.*)" ignoreCase="false" /><action type="Rewrite" url="{R:1}_{R:2}_{R:3}_{R:4}" /><conditions><add input="{REQUEST_FILENAME}" pattern="^.+\.(axd|asmx|ashx|js|css|jpg|png|gif|pdf)$" negate="true" /></conditions></rule><rule name="2" stopProcessing="true"><match url="(.*)-(.*)-(.*)" ignoreCase="false" /><action type="Rewrite" url="{R:1}_{R:2}_{R:3}" /><conditions><add input="{REQUEST_FILENAME}" pattern="^.+\.(axd|asmx|ashx|js|css|jpg|png|gif|pdf)$" negate="true" /></conditions></rule><rule name="1" stopProcessing="true"><match url="(.*)-(.*)" ignoreCase="false" /><action type="Rewrite" url="{R:1}_{R:2}" /><conditions><add input="{REQUEST_FILENAME}" pattern="^.+\.(axd|asmx|ashx|js|css|jpg|png|gif|pdf)$" negate="true" /></conditions></rule><rule name="SearchRedirect" stopProcessing="true"><match url="^SearchResults\.aspx$" /><conditions><add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /><add input="{QUERY_STRING}" pattern="^([^=&]+)=([^=&]+)$" /></conditions><action type="Redirect" url="searchresults/{ToLower:{C:1}/{C:2}}" appendQueryString="false" /></rule><rule name="SearchRewrite" stopProcessing="true"><match url="^SearchResults/([^/]+)/([^/]+)/?$" /><conditions><add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /><add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /></conditions><action type="Rewrite" url="SearchResults.aspx?{R:1}={R:2}" /></rule></rules><outboundRules><rule name="5" preCondition="IsHtml"><match filterByTags="A" pattern="(.*)_(.*)_(.*)_(.*)_(.*)_(.*)" /><action type="Rewrite" value="{R:1}-{R:2}-{R:3}-{R:4}-{R:5}-{R:6}" /></rule><rule name="4" preCondition="IsHtml"><match filterByTags="A" pattern="(.*)_(.*)_(.*)_(.*)_(.*)" /><action type="Rewrite" value="{R:1}-{R:2}-{R:3}-{R:4}-{R:5}" /></rule><rule name="3" preCondition="IsHtml"><match filterByTags="A" pattern="(.*)_(.*)_(.*)_(.*)" /><action type="Rewrite" value="{R:1}-{R:2}-{R:3}-{R:4}" /></rule><rule name="2" preCondition="IsHtml"><match filterByTags="A" pattern="(.*)_(.*)_(.*)" /><action type="Rewrite" value="{R:1}-{R:2}-{R:3}" /></rule><rule name="1" preCondition="IsHtml"><match filterByTags="A" pattern="(.*)_(.*)" /><action type="Rewrite" value="{R:1}-{R:2}" /></rule><rule name="ASPX" preCondition="IsHtml"><match filterByTags="A" pattern="^(.*)\.aspx$" /><action type="Rewrite" value="{ToLower:{R:1}}" /></rule><rule name="SearchRewrite" preCondition="IsHtml"><match filterByTags="A, Form, Img" pattern="^(.*/)SearchResults\.aspx\?Search=([^=&]+)$" /><action type="Rewrite" value="{R:1}searchresults/search/{R:2}/" /></rule><preConditions><preCondition name="IsHtml"><add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /></preCondition></preConditions></outboundRules></rewrite>
Thanks