简体   繁体   English

仅针对ASPX和扩展名较少的URL将URL转换为小写

[英]Convert URL to lower case only for ASPX and extension less URLs

I am using this rule in IIS 7 我在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 我如何对其进行修改,以使其仅重定向用户可能在浏览器中看到的URL,例如/MyPage.aspx和/ MyPage以及/MyPage.htmL

EDIT: I ended up using this: (this solves problem with DotNetNuke and reduces unnecessary redirects) 编辑:我最终使用此:(这解决了DotNetNuke的问题并减少了不必要的重定向)

    <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>

For Extensionless and ASPX only to lowercase: 对于无扩展名和仅用于小写的ASPX:

<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) \\.aspx$匹配以.aspx结尾的文件名( $是行尾)

\\. matches anything with a dot in the file name (that wasn't already matched) and negates it from the match 匹配文件名中带有点的任何内容(尚未匹配),并将其从匹配中取反

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM