【问题标题】:regex to find vanity URLs from IIS rewrite rules正则表达式从 IIS 重写规则中查找虚 URL
【发布时间】:2019-06-24 14:55:30
【问题描述】:

我需要提取所有虚 URL 重定向规则,但排除重定向规则。

    <rule name="welcome2020" stopProcessing="true">
      <match url="welcome2020" />
      <action type="Redirect" url="https://www.mywebsite.org/Pages/.welcome2020aspx" appendQueryString="false" />
    </rule>
    <rule name="Page to Page Redirect">
      <match url="/Staff/Pages/Ashley.aspx" />
      <action type="Rewrite" url="services/Staff/Pages/Ashley.aspx" />
    </rule>

我需要匹配所有不包含.aspx&lt;match url="whatever" /&gt; 类型我唯一想到的是我需要一个负前瞻。但不确定如何实现它。

我基本上需要这样的东西,但对于我的重定向规则。 https://www.regextester.com/15

【问题讨论】:

  • 可能&lt;match url="\.aspx$" negate="true"/&gt; 就足够了。
  • @WiktorStribiżew 不在规则本身中。我已将重写规则导出到一个文件中,在该文件中,我只需要捕获虚荣规则并排除页面到页面重定向..
  • 请添加您尝试使其更清晰的正则表达式。你在用什么工具?
  • 你说你尝试^((?!badword).)*$,但它匹配一个没有badword字符串。您似乎想要匹配以 &lt;match url=" + 无坏词 + " /&gt; 开头的字符串。尝试删除锚点并改用正确的上下文。请注意,您可能需要考虑正确的引号,将 . 替换为 [^"]

标签: regex


【解决方案1】:

你可以试试:

^(?=.*match)(?!.*\.aspx).*

请看DEMO :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-23
    • 1970-01-01
    • 2020-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    相关资源
    最近更新 更多