[英]Convert URL to lower case only for ASPX and extension less URLs
我在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>
我如何对其进行修改,以使其仅重定向用户可能在浏览器中看到的URL,例如/MyPage.aspx和/ MyPage以及/MyPage.htmL
编辑:我最终使用此:(这解决了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>
对于无扩展名和仅用于小写的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$
匹配以.aspx
结尾的文件名( $
是行尾)
\\.
匹配文件名中带有点的任何内容(尚未匹配),并将其从匹配中取反
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.