使用井号标记的IIS重定向页面

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

更新后的规则仍然不起作用,唯一起作用的规则是汽车LandingPage。

 <!--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 -->
wzx1123 回答:使用井号标记的IIS重定向页面

根据您的网址重写规则,我发现您已在InboundRuleTrailingPageNumber网址重写条件中添加了negate =“ true”。

我的意思是,如果网址与cars\/model\/(\w+)\/index.html(\w+)匹配,它将使该网址正常工作。

我建议您可以尝试删除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>
,

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

本文链接:https://www.f2er.com/2933580.html

大家都在问