Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS URL rewrite module url's to lowercase

For better SEO we are using URL rewrite to convert all the URL's to lowercase. I set this one as mentioned in this the below article.

Everything is working fine from URL perspective, but we see lot of 301 redirects when we check in fiddler. It looks like the images, javascript, css, jquery ajax calls and everything is getting converted into lower case. I am trying to remove that and want to rewrite only aspx extension and no extension urls. I tried to play around the matchurl without any success. Any help or guidelines will be highly appricated.

Thanks

Edit: My Current rule is

 <rules>

    <rulename="LowerCaseRule1"patternSyntax="ExactMatch"stopProcessing="true">
      <matchurl="[A-Z]"ignoreCase="false"/>
      <actiontype="Redirect"url="{ToLower:{URL}}"/>
    </rule>
  </rules>
like image 901
Tippu Avatar asked Aug 14 '13 20:08

Tippu


1 Answers

You could probably use something as follow:

<rule name="LowerCaseRule1" 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>

The rule will be triggered only if one of the condition is true:

  • The first one checks if the requested path (filename) ends with .aspx.
  • The second one checks if the if the requested path (filename) doesn't contain a . (so doesn't have an extension)
like image 126
cheesemacfly Avatar answered Sep 27 '22 22:09

cheesemacfly