IIS 使用 hash 标签重定向页面
IIS Redirect page using the hash tag
我的 web.config 中有两个规则,规则名称 InboundRule 正在运行并重定向到正确的 PDF 文件。但是带有尾随页码的第二条规则不是看起来他们都在点击 InboundRule 并且没有添加页码来打开 PDF 文件
Is there a way to match on the page number and open the file to the correct page?
<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 -->
根据您的url重写规则,我发现您在InboundRuleTrailingPageNumber
url重写条件中添加了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>
我遇到的问题与规则的顺序有关。一旦我更正了订单,它就开始工作了。
我的 web.config 中有两个规则,规则名称 InboundRule 正在运行并重定向到正确的 PDF 文件。但是带有尾随页码的第二条规则不是看起来他们都在点击 InboundRule 并且没有添加页码来打开 PDF 文件
Is there a way to match on the page number and open the file to the correct page?
<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 -->
根据您的url重写规则,我发现您在InboundRuleTrailingPageNumber
url重写条件中添加了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>
我遇到的问题与规则的顺序有关。一旦我更正了订单,它就开始工作了。