【问题标题】:IIS 7 URL Rewrite - CamelCase domain and lower case everything elseIIS 7 URL 重写 - CamelCase 域和小写其他所有内容
【发布时间】:2011-06-08 04:40:00
【问题描述】:

我正在尝试使用 URL 重写模块在 iis 7 中为我的站点设置重写规则。如果站点名称是“WonderfulWidgets”

我希望它始终是 http://WonderfulWidgets.com
不是:wonderwidgets.com
不是:WONDERFULWIDGETS.com

我还希望 WonderfulWidgets.com 之后的所有内容都为小写。
IE WonderfulWidgets.com/best-widgets。

我已经完成了小写 url 的重写,我也做到了,所以它会删除 WonderfulWidgets.com 之前的所有前导 www

我的问题是我的小写 URL 重写也降低了域名。 我需要帮助编写 CamelCase 域名,以便将其他所有内容重写为小写。

这是我的 web.config 中的内容:

<rewrite>
        <rules>
            <rule name="CanonicalHostNameRule1">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^WonderfulWidgets\.com$" negate="true" />
                </conditions>
                <action type="Redirect" url="http://WonderfulWidgets.com/{R:1}" />
            </rule>
            <rule name="RemoveTrailingSlashRule1" stopProcessing="true">
                <match url="(.*)/$" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                </conditions>
                <action type="Redirect" url="{R:1}" />
            </rule>
            <rule name="Default Document URL Rewrite" stopProcessing="true">
                <match url="(.*?)/?Default\.aspx$" />
                <action type="Redirect" url="{R:1}/" />
                <conditions>
                    <add input="{URL}" pattern="WebResource.axd" negate="true" />
                </conditions>
            </rule>
        </rules>
    </rewrite>

【问题讨论】:

    标签: iis url-rewriting


    【解决方案1】:

    DNS 名称通常被视为不区分大小写,因此大多数(全部?)网络浏览器在地址栏中以全部小写形式显示域名。据我所知,您无法通过更改您在 HTTP 响应中返回的内容来更改此行为。

    来自RFC 4343

    根据最初的 DNS 设计决策,名称比较 查找 DNS 查询应该不区分大小写。

    来自Wikipedia

    域名以不区分大小写的方式解释。

    浏览器似乎都更喜欢小写。

    【讨论】:

      猜你喜欢
      • 2015-10-25
      • 2010-10-17
      • 1970-01-01
      • 2013-07-01
      • 1970-01-01
      • 2012-12-26
      • 1970-01-01
      • 2020-12-13
      相关资源
      最近更新 更多