IIS URL 将模块 url 重写为小写 [英] IIS URL rewrite module url's to lowercase

查看:32
本文介绍了IIS URL 将模块 url 重写为小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了更好的 SEO,我们使用 URL 重写将所有 URL 转换为小写.我按照 这篇 下面的文章.

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.

从 URL 的角度来看一切正常,但是当我们检查 fiddler 时,我们看到很多 301 重定向.看起来图像、javascript、css、jquery ajax 调用和所有内容都被转换为小写.我正在尝试删除它,并且只想重写 aspx 扩展名而不重写扩展名 url.我试图在 matchurl 上玩,但没有成功.任何帮助或指南都将得到高度应用.

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.

谢谢

我当前的规则是

 <rules>

    <rulename="LowerCaseRule1"patternSyntax="ExactMatch"stopProcessing="true">
      <matchurl="[A-Z]"ignoreCase="false"/>
      <actiontype="Redirect"url="{ToLower:{URL}}"/>
    </rule>
  </rules>

推荐答案

您可能可以使用以下内容:

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:

  • 第一个检查请求的路径(文件名)是否以 .aspx 结尾.
  • 第二个检查请求的路径(文件名)是否不包含.(因此没有扩展名)
  • 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)

这篇关于IIS URL 将模块 url 重写为小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆