[英]IIS URL Rewrite part of filename as folder
我想使用文件名的一部分作为文件夹名称,我的重定向工作但重写不起作用,这是我的 web.config (也有删除文件扩展名的规则):
原文: https://www.ipressnet.com.br/v6/client_tracking.aspx?id=x
重写: https://www.ipressnet.com.br/v6/client/tracking?id=x
这有效:
<rule name="RemoveASPx" enabled="true" stopProcessing="false">
<match url="(.*)\.aspx" />
<action type="Redirect" url="{R:1}" redirectType="Permanent" />
</rule>
<rule name="AddASPx" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
这不起作用:
<rule name="RemoveClient" enabled="true" stopProcessing="false">
<match url="^v6/?$|^client_(.*)$" />
<action type="Redirect" url="client/{R:1}" />
</rule>
<rule name="AddClient" enabled="true">
<match url="^v6/client/(.*)$" negate="false" />
<action type="Rewrite" url="v6/client_{R:1}.aspx" />
</rule>
感谢您的帮助,谢谢!
您可以在同一规则中编写 RemoveASPx 和 RemoveClient。
以下规则可能会满足您的要求。
<rule name="rewrite rule" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{URL}" pattern="^/v6(.*)client_(.*)\.aspx$" />
</conditions>
<action type="Redirect" url="v6{C:1}client/{C:2}" redirectType="Temporary" />
</rule>
<rule name="(.*)" enabled="false">
<match url="(.*)" />
<conditions>
<add input="{URL}" pattern="^/v6/client/(.*)" />
</conditions>
<action type="Rewrite" url="v6/client_{C:1}.aspx" />
</rule>
<rule name="r1" stopProcessing="true">
<match url="v6/(client)?(_)?(.*).aspx" ignoreCase="false" />
<action type="Rewrite" url="v6/{R:1}/{R:3}" />
</rule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.