简体   繁体   English

重写规则以重定向URL

[英]Rewrite rule to redirect URL

I am creating URL as - http://localhost:13490/level1/XYZ/hulhbgma79 我创建的URL为 - http:// localhost:13490 / level1 / XYZ / hulhbgma79
trying to redirect this url on - http://localhost:13490/level1/PQR/HttpHandler.ashx?Id=hulhbgma79 试图重定向此URL - http:// localhost:13490 / level1 / PQR / HttpHandler.ashx?Id = hulhbgma79

In above given example of URL 在上面给出的URL示例中

  1. level1 - this name is changing according to condition, level2 or level3. level1 - 此名称根据条件,级别2或级别3而变化。
  2. XYZ - is virtual module. XYZ - 是虚拟模块。
  3. PQR is a folder in which HttpHandler.ashx is kept. PQR是保存HttpHandler.ashx的文件夹。
  4. Id is querystring parameter veriable. Id是查询字符串参数可验证的。
  5. hulhbgma79 is value passed for querystring parameter. hulhbgma79是querystring参数传递的值。

I have written rule for this condition as bellow - 我已经为这种情况编写了规则 - 如下:

<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>

not working as expected. 没有按预期工作。

Can any one kindly help me to get the solution for the same? 任何人都可以帮助我获得相同的解决方案吗?

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM