URL重写 - 从客户端检测到潜在危险的Request.Path值

时间:2012-11-05 17:18:52

标签: iis url-rewriting iis-7.5

我有许多URL重写规则(它们都列在下面)。当我浏览“http://domain.com”时,我转发到“http://www.domain.com/R:”,并显示“从客户端检测到有潜在危险的Request.Path值”的消息(:) “。我希望能够在没有“www”的情况下浏览网站并正确转发。我不知道如何更新或添加到我现有的重​​写规则。这是.Net网站。我希望社区中有人可以给我任何提示。

<rewrite>
<rules>
    <clear />
    <rule name="Change to Lower" enabled="true">
        <match url="[A-Z]" ignoreCase="false" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
        <action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent" />
    </rule>
    <rule name="Redirect to WWW" enabled="true" stopProcessing="true">
      <match url=".*" ignoreCase="false" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTP_HOST}" pattern="^domain.com$" />
      </conditions>
      <action type="Redirect" url="http://www.domain.com/R:{0}" redirectType="Permanent" />
    </rule>
    <rule name="Redirect StockNo" stopProcessing="true">
        <match url="^vehicles/detail/default\.aspx$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
            <add input="{QUERY_STRING}" pattern="^stockno=([^=&amp;]+)$" />
        </conditions>
        <action type="Redirect" url="{C:1}" appendQueryString="false" />
    </rule>
    <rule name="Rewrite StockNo" stopProcessing="true">
        <match url="^([0-9a-z\ ]+)$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="vehicles/detail/default.aspx?stockno={R:1}" />
    </rule>
    <rule name="Redirect StockNo And Desc" enabled="false" stopProcessing="true">
        <match url="^vehicles/detail/default\.aspx$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
            <add input="{QUERY_STRING}" pattern="^stockno=([^=&amp;]+)&amp;desc=([^=&amp;]+)$" />
        </conditions>
        <action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />
    </rule>
    <rule name="Rewrite StockNo And Desc" enabled="false" stopProcessing="true">
        <match url="^([0-9a-z]+)/([0-9]{4}[^/]+)/?$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="vehicles/detail/default.aspx?stockno={R:1}&amp;desc={R:2}" />
    </rule>
    <rule name="Redirect StockNo Desc And Vin" stopProcessing="true">
        <match url="^vehicles/detail/default\.aspx$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
            <add input="{QUERY_STRING}" pattern="^stockno=([^=&amp;]+)&amp;desc=([^=&amp;]+)&amp;vin=([^=&amp;]+)$" />
        </conditions>
        <action type="Redirect" url="{C:1}/{C:2}/{C:3}" appendQueryString="false" />
    </rule>
    <rule name="Rewrite StockNo Desc And Vin" stopProcessing="true">
        <match url="^([0-9a-z]+)/([0-9]{4}[^/]+)/([0-9a-z]+)/?$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="vehicles/detail/default.aspx?stockno={R:1}&amp;desc={R:2}&amp;vin={R:3}" />
    </rule>
    <rule name="Redirect Make And Model" stopProcessing="true">
        <match url="^vehicles/default\.aspx$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
            <add input="{QUERY_STRING}" pattern="^make=([^=&amp;]+)&amp;model=([^=&amp;]+)$" />
        </conditions>
        <action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />
    </rule>
    <rule name="Rewrite Make And Model" stopProcessing="true">
        <match url="^([a-z\ ]+)/([a-z\ ]+)/?$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="vehicles/default.aspx?make={R:1}&amp;model={R:2}" />
    </rule>
    <rule name="Redirect Make Model And SubModel" stopProcessing="true">
        <match url="^vehicles/default\.aspx$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
            <add input="{QUERY_STRING}" pattern="^make=([^=&amp;]+)&amp;model=([^=&amp;]+)&amp;submodel=([^=&amp;]+)$" />
        </conditions>
        <action type="Redirect" url="{C:1}/{C:2}/{C:3}" appendQueryString="false" />
    </rule>
    <rule name="Rewrite Make Model And SubModel" stopProcessing="true">
        <match url="^([a-z\ ]+)/([a-z\ ]+)/([a-z\ ]+)/?$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="vehicles/default.aspx?make={R:1}&amp;model={R:2}&amp;submodel={R:3}" />
    </rule>
    <rule name="Redirect Make An Offer StockNo" stopProcessing="true">
        <match url="^Vehicles/Make-An-Offer\.aspx$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
            <add input="{QUERY_STRING}" pattern="^stockno=([^=&amp;]+)$" />
        </conditions>
        <action type="Redirect" url="Vehicles/Make-An-Offer/{C:1}" appendQueryString="false" />
    </rule>
    <rule name="Rewrite Make An Offer StockNo" stopProcessing="true">
        <match url="^Vehicles/Make-An-Offer/([^/]+)/?$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="Vehicles/Make-An-Offer.aspx?stockno={R:1}" />
    </rule>
    <rule name="Redirect Make An Offer StockNo And Desc" stopProcessing="true">
        <match url="^Vehicles/Make-An-Offer\.aspx$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
            <add input="{QUERY_STRING}" pattern="^stockno=([^=&amp;]+)&amp;desc=([^=&amp;]+)$" />
        </conditions>
        <action type="Redirect" url="Vehicles/Make-An-Offer/{C:1}/{C:2}" appendQueryString="false" />
    </rule>
    <rule name="Rewrite Make An Offer StockNo And Desc" stopProcessing="true">
        <match url="^Vehicles/Make-An-Offer/([^/]+)/([^/]+)/?$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="Vehicles/Make-An-Offer.aspx?stockno={R:1}&amp;desc={R:2}" />
    </rule>
    <rule name="Redirect to Default" enabled="true">
        <match url="(.*)default.aspx" ignoreCase="false" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
        <action type="Redirect" url="{R:1}" redirectType="Permanent" />
    </rule>
    <rule name="Add Trailing Slash" enabled="true">
        <match url="[^/]$" ignoreCase="false" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{URL}" pattern="\.axd$" ignoreCase="false" negate="true" />
        </conditions>
        <action type="Redirect" url="{URL}/" appendQueryString="false" redirectType="Permanent" />
    </rule>
</rules>
<outboundRules>
    <preConditions>
        <preCondition name="ResponseIsHtml1">
            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
        </preCondition>
    </preConditions>
</outboundRules>
<rewriteMaps>
    <rewriteMap name="test" />
</rewriteMaps>

1 个答案:

答案 0 :(得分:2)

在你的第二条规则中,似乎 R:未括在括号中:

http://www.domain.com/R:{0}应为http://www.domain.com/{R:0}