【发布时间】:2021-12-22 06:16:56
【问题描述】:
我在重写规则方面不是最棒的,但我正在尝试根据查询字符串将文件重命名为下载,例如像这样https://example.com/images/02ec1c94de50.jpg?download=1&filename=renamethefiletothis.jpg
这是我的规则,目前将文件硬编码为 thisfile.jpg 我想获取 URL 参数文件名并替换 thisfile.jpg
<rule name="Downloadthefile">
<match serverVariable="RESPONSE_Content_Disposition" pattern=".*" />
<action type="Rewrite" value="attachment;filename=thisfile.jpg" />
<conditions>
<add input="{QUERY_STRING}" pattern="(^|&)download=1(&|$)"/>
</conditions>
</rule>
谢谢
【问题讨论】:
-
我不太明白你的意思。你的目标网址是什么?你想把这个 URL 改写成什么?
-
它是在下载时重命名文件,因此当有人单击链接时,文件将以特定名称下载,我主要使用当前规则
标签: iis download url-rewriting url-rewrite-module content-disposition