Redirect IIS使用哈希标记重定向页面
我的web.config中有两条规则规则名InboundRule正在运行,并重定向到正确的PDF文件。但是第二个规则是,后面的页码不是。看起来他们都符合InboundRule,没有添加页码来打开PDF文件 有没有办法匹配页码并将文件打开到正确的页面Redirect IIS使用哈希标记重定向页面,redirect,iis,iis-7,Redirect,Iis,Iis 7,我的web.config中有两条规则规则名InboundRule正在运行,并重定向到正确的PDF文件。但是第二个规则是,后面的页码不是。看起来他们都符合InboundRule,没有添加页码来打开PDF文件 有没有办法匹配页码并将文件打开到正确的页面 更新的规则仍不起作用唯一起作用的规则是cars LandingPage <!--Cars LandingPage--> <rule name="PatientGLInboundRule" enabled="true" stop
更新的规则仍不起作用唯一起作用的规则是cars 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 -->
根据您的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>
我遇到的问题与规则的顺序有关。一旦我纠正了顺序,一切都开始起作用了
<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>