2

I am using this rule in IIS 7

<rule name="Convert to lower case" enabled="true" stopProcessing="true">
  <match url=".*[A-Z].*" ignoreCase="false" />
  <conditions>
    <add input="{URL}" pattern="(.*)/admin/*" negate="true" />
  </conditions>
  <action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
</rule>

How do I modify it so that it only redirects the urls that the user is likely to see in the browser like /MyPage.aspx and /MyPage and perhaps /MyPage.htmL

EDIT: I ended up using this: (this solves problem with DotNetNuke and reduces unnecessary redirects)

    <rule name="Convert to lower case" enabled="true" stopProcessing="true">
      <match url=".*[A-Z].*" ignoreCase="false" />
      <conditions>
        <add input="{URL}" pattern="(.*)/(admin|desktopmodules|host|tabid)/*" negate="true" />
        <add input="{URL}" pattern="^.*\.(xml|ashx|axd|css|js|jpg|jpeg|png|gif)$" negate="true" ignoreCase="true" />
      </conditions>
      <action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
    </rule>
Vaibhav Garg
  • 3,630
  • 3
  • 33
  • 55
  • May I ask you why (just out of curiosity)? – cheesemacfly Sep 19 '13 at 21:16
  • One reason is to reduce unnecessary redirects as the content contains all sorts of mixed case urls like images, css, js etc. There is no point is redirecting them to lowercase. Second is this generic rule breaks functionality in DNN as it has many virtual pages. – Vaibhav Garg Sep 20 '13 at 04:58
  • Makes sense! Could this help: http://stackoverflow.com/a/18260045/1443490 ? – cheesemacfly Sep 20 '13 at 14:18

1 Answers1

1

For Extensionless and ASPX only to lowercase:

<rule name="LowerCaseRule" stopProcessing="true">
  <match url="[A-Z]" ignoreCase="false" />
  <action type="Redirect" url="{ToLower:{URL}}" />
  <conditions logicalGrouping="MatchAny">
    <add input="{REQUEST_FILENAME}" pattern="\.aspx$" />
    <add input="{REQUEST_FILENAME}" pattern="\." negate="true" />
  </conditions>
</rule>

\.aspx$ matches file names that end with .aspx ($ is end of line)

\. matches anything with a dot in the file name (that wasn't already matched) and negates it from the match

mynameiscoffey
  • 15,244
  • 5
  • 33
  • 45