【问题标题】:IIS Redirect page using the hash tag使用哈希标记的 IIS 重定向页面
【发布时间】:2019-12-12 14:06:25
【问题描述】:

我的 web.config 中有两条规则,规则名称 InboundRule 正在工作,并重定向到正确的 PDF 文件。但是带有尾随页码的第二条规则不是看起来他们都在点击 InboundRule 并且没有添加页码来打开 PDF 文件

有没有办法匹配页码并将文件打开到正确的页面?

<rule name="InboundRule" enabled="true" stopProcessing="true">
             <match url="cars\/model\/(\w+)\/index.html" />
                <conditions trackAllCaptures="false">
                    <add input="{HTTP_HOST}" pattern="cars\/\/(\w+)\/index.html" negate="true"/>
                </conditions>
                <action type="Redirect" url="/cars/model/content/PDF/{R:1}.pdf" logRewrittenUrl="true"/>
        </rule>


        <rule name="InboundRuleTrailingPageNumber" enabled="true" stopProcessing="true">
             <match url="cars\/model\/(\w+)\/index.html(\w+)" />
                <conditions trackAllCaptures="false">
                    <add input="{REQUEST_URI}" pattern="cars\/model\/(\w+)\/index.html(\w+)" negate="true"/>
                </conditions>
                 <action type="Redirect" url="/cars/model/content/PDF/{R:1}.pdf#page={R:2}" logRewrittenUrl="true"/>
        </rule>

更新的规则仍然无效,唯一有效的规则是汽车着陆页。

 <!--Cars LandingPage-->
<rule name="PatientGLInboundRule" enabled="true" stopProcessing="true">
     <match url="cars\/model\/(.*)\/index.html" />
        <conditions trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="cars\/model\/(.*)\/index.html" negate="true"/>
        </conditions>
        <action type="Redirect" url="/cars/model/content/PDF/{R:1}-File.pdf" logRewrittenUrl="true"/>
</rule>
<!--Cars LandingPage -->
<!--Cars Page Number within URL -->
<rule name="CarsInboundRulePageNumberInURL" enabled="true" stopProcessing="true">
     <match url="cars\/model\/(.*)\/(.*)\/index.html" />
        <conditions trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="cars\/model\/(.*)\/(.*)\/index.html" negate="true"/>
        </conditions>
        <action type="Redirect" url="/cars/model/content/PDF/{R:1}-File.pdf#page={R:2}" logRewrittenUrl="true"/>
</rule>
<!--Cars Page Number within URL -->
<!--Cars Trailing Page Number -->
<rule name="CarsInboundRuleTrailingPageNumber" enabled="true" stopProcessing="true">
     <match url="cars\/model\/(.*)\/index.html#(.*)" />
        <conditions trackAllCaptures="false">
            <add input="{REQUEST_URI}" pattern="cars\/model\/(.*)\/index.html(.*)" negate="true"/>
        </conditions>
         <action type="Redirect" url="/cars/model/content/PDF/{R:1}-File.pdf#page={R:2}" logRewrittenUrl="true"/>
</rule>
<!--Cars Trailing Page Number -->

【问题讨论】:

    标签: redirect iis iis-7


    【解决方案1】:

    根据你的url重写规则,我发现你在InboundRuleTrailingPageNumberurl重写条件中添加了negate="true"。

    我的意思是如果 url 匹配 cars\/model\/(\w+)\/index.html(\w+),它将使 url 工作。

    我建议您可以尝试删除negate="true" 并重试。

    更多细节,你可以参考以下规则:

    <rule name="InboundRule" enabled="true" stopProcessing="true">
        <rule name="InboundRuleTrailingPageNumber" enabled="true" stopProcessing="true">
                 <match url="cars\/model\/(\w+)\/index.html(\w+)" />
    
                     <action type="Redirect" url="/cars/model/content/PDF/{R:1}.pdf#page={R:2}" logRewrittenUrl="true"/>
            </rule>
                 <match url="cars\/model\/(\w+)\/index.html" />
                    <conditions trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="cars\/\/(\w+)\/index.html" negate="true"/>
                    </conditions>
                    <action type="Redirect" url="/cars/model/content/PDF/{R:1}.pdf" logRewrittenUrl="true"/>
            </rule>
    

    【讨论】:

      【解决方案2】:

      我遇到的问题与规则的顺序有关。一旦我更正了订单,它就开始起作用了。

      【讨论】:

        猜你喜欢
        • 2011-09-09
        • 2012-02-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-01
        • 1970-01-01
        相关资源
        最近更新 更多