从 url 中删除默认文档,而不删除以默认文档名称结尾的文件

问题描述 投票:0回答:2
regex iis
2个回答
0
投票

请尝试在 web.config 中使用以下重写规则:

<rule name="efault document rewrite" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" pattern="index.asp" />
                </conditions>
                <action type="Redirect" url="{R:1}" redirectType="Temporary" />
            </rule>

0
投票

你可以使用这个正则表达式:

^(.+/)?index.asp$

此匹配:

  • ^
    :字符串开头
  • (.+/)?
    :可选,一些字符后跟
    /
  • index.asp
    :字面上,
    index.asp
  • $
    :字符串结尾

regex101 上的正则表达式演示

© www.soinside.com 2019 - 2024. All rights reserved.