gpt4 book ai didi

c# - 重写规则以重定向 URL

转载 作者:行者123 更新时间:2023-11-30 17:28:36 25 4
gpt4 key购买 nike

我创建的 URL 为 - http://localhost:13490/level1/XYZ/hulhbgma79
试图将此 URL 重定向到 - http://localhost:13490/level1/PQR/HttpHandler.ashx?Id=hulhbgma79

在上面给出的 URL 示例中

  1. level1 - 此名称根据条件、level2 或 level3 而变化。
  2. XYZ - 是虚拟模块。
  3. PQR 是存放 HttpHandler.ashx 的文件夹。
  4. Id 是可验证的查询字符串参数。
  5. hulhbgma79 是为查询字符串参数传递的值。

我已经为这种情况编写了如下规则 -

<rule name="RewriteURL" stopProcessing="true">
<match url="^XYZ\/((([A-Za-z0-9]+)(\s|&amp;)([^\/]+))|(([^\/]+)(\s|&amp;))|([^\/]+))\/?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="{R:1}/PQR/HttpHandler.ashx?Id={R:9}" />

</rule>

没有按预期工作。

任何人都可以帮助我获得相同的解决方案吗?

最佳答案

<rule name="RewriteURL" stopProcessing="true">
<match url="(level\d)\/XYZ\/((([A-Za-z0-9]+)(\s|&amp;)([^\/]+))|(([^\/]+)(\s|&amp;))|([^\/]+))\/?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="{R:1}/PQR/HttpHandler.ashx?Id={R:2}" />

</rule>

关于c# - 重写规则以重定向 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52567161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com