簡體   English   中英

重寫規則以重定向URL

[英]Rewrite rule to redirect URL

我創建的URL為 - http:// localhost:13490 / level1 / XYZ / hulhbgma79
試圖重定向此URL - http:// localhost:13490 / level1 / PQR / HttpHandler.ashx?Id = hulhbgma79

在上面給出的URL示例中

  1. level1 - 此名稱根據條件,級別2或級別3而變化。
  2. XYZ - 是虛擬模塊。
  3. PQR是保存HttpHandler.ashx的文件夾。
  4. Id是查詢字符串參數可驗證的。
  5. hulhbgma79是querystring參數傳遞的值。

我已經為這種情況編寫了規則 - 如下:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM