IIS URL rewrite module url's to lowercase

。_饼干妹妹 提交于 2019-11-28 02:45:34

问题


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>

回答1:


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)


来源:https://stackoverflow.com/questions/18241378/iis-url-rewrite-module-urls-to-lowercase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!