![](/img/trans.png)
[英]IIS URL Rewrite/Redirect Remove trailing Question mark from Request URL, if no query string Parameter exists in URL
[英]IIS 7.5 Url Rewrite ignoring question mark
我正在尝试在IIS 7.5网址重写中创建重写规则。 我要实现的目标是,当有人单击某个pdf文件时,我希望他们被重定向到一个表单,然后当他们填写该表单时,他们得到的是带有问号的pdf文件。 例如,在通过重写规则的末尾附加了?download=true
,因此:
pdf/my-pdf-file.pdf will be redirected to go-to-this-file.aspx
(这是一种形式)
然后将它们重定向到:
pdf/my-pdfpfile.pdf?download=true
哪些重写规则不应该采用,但是确实是我的问题。
这是我的规则:
<system.webServer>
<rewrite>
<rules>
<rule name="My PDF Rule">
<match url="^pdf/my-pdf-file.pdf$" ignoreCase="true" />
<action type="Rewrite" url="/go-to-this-file.aspx" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
请有人帮忙。 干杯!
问题很简单,您应该检查{QUERY_STRING}
包含download=true
,然后不要重定向。 尝试这个:
<system.webServer>
<rewrite>
<rules>
<rule name="My PDF Rule">
<match url="^pdf/my-pdf-file.pdf$" ignoreCase="true" />
<conditions>
<add input="{QUERY_STRING}" pattern="download=true" negate="true" />
</conditions>
<action type="Rewrite" url="/go-to-this-file.aspx" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.